File Operations
NSFileManager also abstracts out a number of common file operations, such as copying, moving, removing, and linking items. As expected, there are two API families: one using string paths and the other using URLs.
Path operations
You can use the following methods to copy, move, (hard) link, and remove files and directories:
- (BOOL) copyItemAtPath: (NSString *) srcPath toPath: (NSString *) dstPath error: (NSError **) error;
- (BOOL) moveItemAtPath: (NSString *) srcPath toPath: (NSString *) dstPath error: (NSError **) error;
- (BOOL) linkItemAtPath: (NSString *) srcPath toPath: (NSString *) dstPath error: (NSError **) error;
- (BOOL) removeItemAtPath: (NSString *) path error: (NSError **) error;
These methods will potentially ...
Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.