#import <sys/xattr.h>
+ (NSString *)getFullFilePathInDocuments:(NSString *)subFilePath fileName:(NSString *)fileName
{
NSString *filePath = [NSString stringWithFormat:@"%@/Documents%@", NSHomeDirectory(), subFilePath];
// NSLog(@"function:%s,getFilePath %@", __FUNCTION__,filePath);
NSFileManager* fm = [NSFileManager defaultManager];
if ([fm fileExistsAtPath:filePath]) {
return [NSString stringWithFormat:@"%@/%@", filePath, fileName];
}
if ([fm createDirectoryAtPath:filePath
withIntermediateDirectories:YES
attributes:nil
error:nil])
{
u_int8_t b = 1;
setxattr([filePath fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);
return [NSString stringWithFormat:@"%@/%@", filePath, fileName];
}
return nil;
}
self.mFile = [MagicEntity getFullFilePathInDocuments:@"/test" fileName:@"yuv.bin"];
NSData *data = [[NSData alloc] initWithBytes:I420 length:w * h * 3 / 2];
bool r = [data writeToFile:self.mFile atomically:true];