获取文件相关信息,创建时间,修改时间等;
-(NSString*)bundleCreateDate {
NSBundle* mainBundle = [NSBundle mainBundle];
NSString* bPath = mainBundle.bundlePath;
NSError* error = nil;
NSDictionary* fileAttribs = [[NSFileManager defaultManager] attributesOfItemAtPath:bPath error:&error];
NSDate* creationDate = [fileAttribs fileCreationDate];
// NSDate* modifyData = [fileAttribs fileModificationDate];
NSString* createDate = [NSString stringWithFormat:@"%ld", (NSInteger)creationDate.timeIntervalSince1970];
return createDate;
}
获取文件最近打开时间:
-(NSDate *)getFileAccessLastDateOfFile:(NSString *)aFilePath {
struct stat output;
int ret = stat([aFilePath fileSystemRepresentation], &output);
struct timespec accessTime = output.st_atimespec;
NSDate *aDate = [NSDate dateWithTimeIntervalSince1970:accessTime.tv_sec];
return aDate;
}
获取info.list的版本信息
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];