Sunday, April 21, 2013

NSFileManager attributesOfFileSystemForPath example objc


attributesOfFileSystemForPath:error:

Returns a dictionary that describes the attributes of the mounted file system on which a given path resides.
- (NSDictionary *)attributesOfFileSystemForPath:(NSString *)path error:(NSError**)error
Parameters
path
Any pathname within the mounted file system.
error
On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.
Return Value of (NSFileManager attributesOfFileSystemForPath)
An NSDictionary object that describes the attributes of the mounted file system on which path resides. See “File-System Attribute Keys” for a description of the keys available in the dictionary.
Discussion
This method does not traverse a terminal symbolic link.
Example of [NSFileManager attributesOfFileSystemForPath: error:]

NSDictionary* fileAttributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:@"/"
                                                                                   error:&error];
unsigned long long freeSpace = [[fileAttributes objectForKey:NSFileSystemFreeSize] longLongValue];
NSLog(@"free disk space: %dGB", (int)(freeSpace / 1073741824));