Skip to content

Instantly share code, notes, and snippets.

@fukata
Created March 6, 2012 02:14
Show Gist options
  • Save fukata/1982914 to your computer and use it in GitHub Desktop.
Save fukata/1982914 to your computer and use it in GitHub Desktop.
iOS file informations.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *dir = [paths objectAtIndex:0];
NSLog(@"dir=%@", dir);
NSString *filePath = [dir stringByAppendingPathComponent:@"hoge.flv"];
NSLog(@"filePath=%@", filePath);
NSFileManager *fm = [NSFileManager defaultManager];
BOOL exists = [fm fileExistsAtPath:filePath isDirectory:NO];
BOOL writable = [fm isWritableFileAtPath:filePath];
BOOL readable = [fm isReadableFileAtPath:filePath];
BOOL executable = [fm isExecutableFileAtPath:filePath];
NSDictionary *file = [fm attributesOfItemAtPath:filePath error:nil];
NSLog(@"exists=%d, writable=%d, readable=%d, executable=%d, size=%lld", exists, writable, readable, executable, [file fileSize]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment