【发布时间】:2013-02-27 03:30:05
【问题描述】:
如果我只需要知道文件是否为文件夹/符号链接及其大小,是否可以使用更快的文件系统 API。我目前正在使用 [NSFileManager attributesOfItemAtPath...] 并且只有 NSFileSize 和 NSFileType。
是否有我应该使用的批量文件系统枚举 API?我怀疑这可能会更快,而无需跳入和跳出用户代码。
我的目标是通过目录快速递归以获得文件夹的真实文件大小,当前调用 attributesOfItemAtPath 是我 95% 的瓶颈。
我目前正在使用的一些代码:
NSDictionary* properties = [fileManager attributesOfItemAtPath:filePath error:&error];
long long fileSize = [[properties objectForKey:NSFileSize] longLongValue];
NSObject* fileType = [[properties objectForKey:NSFileType isEqual:NSFileTypeDirectory];
【问题讨论】:
-
只是一个疯狂的猜测,比如stackoverflow.com/questions/5749488/… ?
标签: objective-c c performance cocoa nsfilemanager