码迷,mamicode.com
首页 > 移动开发 > 详细

IOS Intro - Write file

时间:2017-06-27 18:40:18      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:default   mic   ati   for   entity   attr   byte   file   documents   

 

 

 

#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];

IOS Intro - Write file

标签:default   mic   ati   for   entity   attr   byte   file   documents   

原文地址:http://www.cnblogs.com/avcs/p/7086344.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!