| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in Mac OS X v10.0 and later.
|
| Companion guide | |
| Declared in | NSFileManager.h |
NSFileManager enables you to perform many generic file-system operations and insulates an application from the underlying file system.
– movePath:toPath:handler:
– fileManager:shouldMoveItemAtPath:toPath: delegate method
– moveItemAtPath:toPath:error:
– fileManager:shouldProceedAfterError:movingItemAtPath:toPath: delegate method
– copyPath:toPath:handler:
– fileManager:shouldCopyItemAtPath:toPath: delegate method
– copyItemAtPath:toPath:error:
– fileManager:shouldProceedAfterError:copyingItemAtPath:toPath: delegate method
– removeFileAtPath:handler:
– fileManager:shouldRemoveItemAtPath: delegate method
– removeItemAtPath:error:
– fileManager:shouldProceedAfterError:removingItemAtPath: delegate method
– createDirectoryAtPath:attributes:
– createDirectoryAtPath:withIntermediateDirectories:attributes:error:
– createFileAtPath:contents:attributes:
– linkPath:toPath:handler:
– fileManager:shouldLinkItemAtPath:toPath: delegate method
– linkItemAtPath:toPath:error:
– fileManager:shouldProceedAfterError:linkingItemAtPath:toPath: delegate method
– createSymbolicLinkAtPath:pathContent:
– createSymbolicLinkAtPath:withDestinationPath:error:
– pathContentOfSymbolicLinkAtPath:
– destinationOfSymbolicLinkAtPath:error:
The methods described in this section are methods to be implemented by the callback handler passed to several methods of NSFileManager.
– fileManager:shouldProceedAfterError: delegate method
– fileManager:willProcessPath: delegate method
– directoryContentsAtPath:
– contentsOfDirectoryAtPath:error:
– enumeratorAtPath:
– subpathsAtPath:
– subpathsOfDirectoryAtPath:error:
– fileExistsAtPath:
– fileExistsAtPath:isDirectory:
– isReadableFileAtPath:
– isWritableFileAtPath:
– isExecutableFileAtPath:
– isDeletableFileAtPath:
– componentsToDisplayForPath:
– displayNameAtPath:
– fileAttributesAtPath:traverseLink:
– attributesOfItemAtPath:error:
– fileSystemAttributesAtPath:
– attributesOfFileSystemForPath:error:
– changeFileAttributes:atPath:
– setAttributes:ofItemAtPath:error:
Returns the default NSFileManager object for the file system.
+ (NSFileManager *)defaultManager
The default NSFileManager object for the file system.
You invoke all NSFileManager instance methods with this object as the receiver.
NSFileManager.hReturns a dictionary that describes the attributes of the mounted file system on which a given path resides.
- (NSDictionary *)attributesOfFileSystemForPath:(NSString *)patherror:(NSError **)error
Any pathname within the mounted file system.
If an error occurs, upon return contains an NSError object that describes the problem. Pass NULL if you do not want error information.
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.
This method does not traverse an initial symbolic link.
NSFileManager.hAn NSDictionary object containing the attributes of the item at a given path.
- (NSDictionary *)attributesOfItemAtPath:(NSString *)patherror:(NSError **)error
The path of a file or directory.
If an error occurs, upon return contains an NSError object that describes the problem. Pass NULL if you do not want error information.
An NSDictionary object that describes the attributes (file, directory, symlink, and so on) of the file specified by path. The keys in the dictionary are described in “File Attribute Keys”.
This method does not traverse an initial symbolic link.
NSFileManager.hChanges the path of the current directory for the current process to a given path.
- (BOOL)changeCurrentDirectoryPath:(NSString *)path
The path of the directory to which to change.
YES if successful, otherwise NO.
All relative pathnames refer implicitly to the current working directory. The current working directory is stored per process.
– currentDirectoryPath– fileExistsAtPath:isDirectory:– directoryContentsAtPath:– createDirectoryAtPath:withIntermediateDirectories:attributes:error:– createDirectoryAtPath:attributes:NSFileManager.hChanges the attributes of a given file or directory.
- (BOOL)changeFileAttributes:(NSDictionary *)attributes atPath:(NSString *)path
A dictionary containing as keys the attributes to set for path and as values the corresponding value for the attribute. You can set following: NSFileBusy, NSFileCreationDate, NSFileExtensionHidden, NSFileGroupOwnerAccountID, NSFileGroupOwnerAccountName, NSFileHFSCreatorCode, NSFileHFSTypeCode, NSFileImmutable, NSFileModificationDate, NSFileOwnerAccountID, NSFileOwnerAccountName, NSFilePosixPermissions. You can change single attributes or any combination of attributes; you need not specify keys for all attributes.
For the NSFilePosixPermissions value, specify a file mode from the OR’d permission bit masks defined in sys/stat.h. See the man page for the chmod function (man 2 chmod) for an explanation.
A path to a file or directory.
YES if all changes succeed. If any change fails, returns NO, but it is undefined whether any changes actually occurred.
As in the POSIX standard, the application either must own the file or directory or must be running as superuser for attribute changes to take effect. The method attempts to make all changes specified in attributes and ignores any rejection of an attempted modification.
The NSFilePosixPermissions value must be initialized with the code representing the POSIX file-permissions bit pattern. NSFileHFSCreatorCode and NSFileHFSTypeCode will only be heeded when path specifies a file.
On Mac OS X v10.5 and later, use setAttributes:ofItemAtPath:error: instead.
NSFileManager.hReturns an array of NSString objects representing the user-visible components of a given path.
- (NSArray *)componentsToDisplayForPath:(NSString *)path
A pathname.
An array of NSString objects representing the user-visible (for the Finder, Open and Save panels, and so on) components of path.
These components cannot be used for path operations and are only suitable for display to the user.
NSFileManager.hReturns as an NSData object the contents of the file at at given path.
- (NSData *)contentsAtPath:(NSString *)path
The path of a file.
The contents of the file specified by path as an NSData object. If path specifies a directory, or if some other error occurs, returns nil.
NSFileManager.hReturns a Boolean value that indicates whether the files or directories in specified paths have the same contents.
- (BOOL)contentsEqualAtPath:(NSString *)path1 andPath:(NSString *)path2
The path of a file or directory to compare with the contents of path2.
The path of a file or directory to compare with the contents of path1.
YES if file or directory specified in path1 has the same contents as that specified in path2, otherwise NO.
If path1 and path2 are directories, the contents are the list of files and subdirectories each contains—contents of subdirectories are also compared. For files, this method checks to see if they’re the same file, then compares their size, and finally compares their contents. This method does not traverse symbolic links, but compares the links themselves.
NSFileManager.hReturns an array of NSString objects identifying the directories and files (including symbolic links) contained in a given directory.
- (NSArray *)contentsOfDirectoryAtPath:(NSString *)patherror:(NSError **)error
A path to a directory.
If an error occurs, upon return contains an NSError object that describes the problem. Pass NULL if you do not want error information.
An array of NSString objects identifying the directories and files (including symbolic links) contained in path. Returns an empty array if the directory exists but has no contents. Returns nil if the directory specified at path does not exist or there is some other error accessing it.
The search is shallow and therefore does not return the contents of any subdirectories. This returned array does not contain strings for the current directory (“.”), parent directory (“..”), or resource forks (begin with “._”) and does not traverse symbolic links.
– directoryContentsAtPath:– currentDirectoryPath– fileExistsAtPath:isDirectory:– enumeratorAtPath:– subpathsAtPath:NSFileManager.hCopies the directory or file specified in a given path to a different location in the file system identified by another path.
- (BOOL)copyItemAtPath:(NSString *)srcPathtoPath:(NSString *)dstPatherror:(NSError **)error
The path of a file or directory.
The path of a file or directory.
If an error occurs, upon return contains an NSError object that describes the problem. Pass NULL if you do not want error information.
YES if the operation was successful, otherwise NO.
– fileManager:shouldCopyItemAtPath:toPath:– fileManager:shouldProceedAfterError:copyingItemAtPath:toPath:– linkItemAtPath:toPath:error:– moveItemAtPath:toPath:error:– removeItemAtPath:error:– copyPath:toPath:handler:NSFileManager.hCopies the directory or file specified in a given path to a different location in the file system identified by another path.
- (BOOL)copyPath:(NSString *)source toPath:(NSString *)destination handler:(id)handler
The location of the source file.
The location to which to copy the file specified by source.
An object that responds to the callback messages fileManager:willProcessPath: and fileManager:shouldProceedAfterError:. You can specify nil for handler; if you do so and an error occurs, the method automatically returns NO.
YES if the copy operation is successful. If the operation is not successful, but the callback handler of fileManager:shouldProceedAfterError: returns YES, copyPath:toPath:handler: also returns YES. Otherwise this method returns NO. The method also attempts to make the attributes of the directory or file at destination identical to source, but ignores any failure at this attempt.
If source is a file, the method creates a file at destination that holds the exact contents of the original file (this includes BSD special files). If source is a directory, the method creates a new directory at destination and recursively populates it with duplicates of the files and directories contained in source, preserving all links. The file specified in source must exist, while destination must not exist prior to the operation. When a file is being copied, the destination path must end in a filename—there is no implicit adoption of the source filename. Symbolic links are not traversed but are themselves copied. File or directory attributes—that is, metadata such as owner and group numbers, file permissions, and modification date—are also copied.
The handler callback mechanism is similar to delegation. NSFileManager sends fileManager:willProcessPath: when it begins a copy, move, remove, or link operation. It sends fileManager:shouldProceedAfterError: when it encounters any error in processing.
This code fragment verifies that the file to be copied exists and then copies that file to the user’s ~/Library/Reports directory:
NSString *source = @"/tmp/quarterly_report.rtf"; |
NSString *destination = [[[NSHomeDirectory() |
stringByAppendingPathComponent:@"Library"] |
stringByAppendingPathComponent:@"Reports"] |
stringByAppendingPathComponent:@"new_quarterly_report.rtf"]; |
NSFileManager *fileManager = [NSFileManager defaultManager]; |
if ([fileManager fileExistsAtPath:source]) { |
[fileManager copyPath:source toPath:destination handler:nil]; |
} |
– linkPath:toPath:handler:– movePath:toPath:handler:– fileManager:shouldProceedAfterError:– removeFileAtPath:handler:– fileManager:willProcessPath:NSFileManager.hCreates a directory (without contents) at a given path with given attributes.
- (BOOL)createDirectoryAtPath:(NSString *)path attributes:(NSDictionary *)attributes
The path at which to create the new directory. The directory to be created must not yet exist, but its parent directory must exist.
The file attributes for the new directory. The attributes you can set are owner and group numbers, file permissions, and modification date. If you specify nil for attributes, default values for these attributes are set (particularly write access for the creator and read access for others). The “Constants” section lists the global constants used as keys in the attributes dictionary. Some of the keys, such as NSFileHFSCreatorCode and NSFileHFSTypeCode, do not apply to directories.
YES if the operation was successful, otherwise NO.
On Mac OS X v10.5 and later, use createDirectoryAtPath:withIntermediateDirectories:attributes:error: instead.
– createDirectoryAtPath:withIntermediateDirectories:attributes:error:– changeCurrentDirectoryPath:– changeFileAttributes:atPath:– createFileAtPath:contents:attributes:– currentDirectoryPathNSFileManager.hCreates a directory with given attributes at a specified path.
- (BOOL)createDirectoryAtPath:(NSString *)pathwithIntermediateDirectories:(BOOL)createIntermediatesattributes:(NSDictionary *)attributeserror:(NSError **)error
The path at which to create the new directory. The directory to be created must not yet exist.
If YES, then the method will also create any necessary intermediate directories; if NO, then the method will fail if any parent of the directory to be created does not exist.
The file attributes for the new directory. The attributes you can set are owner and group numbers, file permissions, and modification date. If you specify nil for attributes, the directory is created according to the umask of the process. The “Constants” section lists the global constants used as keys in the attributes dictionary. Some of the keys, such as NSFileHFSCreatorCode and NSFileHFSTypeCode, do not apply to directories.
If an error occurs, upon return contains an NSError object that describes the problem. Pass NULL if you do not want error information.
YES if the operation was successful, otherwise NO.
– createDirectoryAtPath:attributes:– changeCurrentDirectoryPath:– setAttributes:ofItemAtPath:error:– createFileAtPath:contents:attributes:– currentDirectoryPathNSFileManager.hCreates a file at a given path that has given attributes and contents.
- (BOOL)createFileAtPath:(NSString *)path contents:(NSData *)contents attributes:(NSDictionary *)attributes
The path for the new file.
The contents for the new file.
A dictionary that describes the attributes of the new file. The file attributes you can set are owner and group numbers, file permissions, and modification date. “File Attribute Keys” lists the global constants used as keys in the attributes dictionary. If you specify nil for attributes, the file is given a default set of attributes.
YES if the operation was successful, otherwise NO.
– contentsAtPath:– changeFileAttributes:atPath:– setAttributes:ofItemAtPath:error:– fileAttributesAtPath:traverseLink:– attributesOfItemAtPath:error:NSFileManager.hCreates a symbolic link identified by a given path that refers to a given location.
- (BOOL)createSymbolicLinkAtPath:(NSString *)path pathContent:(NSString *)otherPath
The path for a symbolic link.
The path to which path should refer.
YES if the operation is successful, otherwise NO. Returns NO if a file, directory, or symbolic link identical to path already exists.
Creates a symbolic link identified by path that refers to the location otherPath in the file system.
On Mac OS X v10.5 and later, use createSymbolicLinkAtPath:withDestinationPath:error: instead.
– createSymbolicLinkAtPath:withDestinationPath:error:– pathContentOfSymbolicLinkAtPath:– linkPath:toPath:handler:NSFileManager.hCreates a symbolic link identified by a given path that refers to a given location.
- (BOOL)createSymbolicLinkAtPath:(NSString *)pathwithDestinationPath:(NSString *)destPatherror:(NSError **)error
The path for a symbolic link.
The path to which path should refer.
If an error occurs, upon return contains an NSError object that describes the problem. Pass NULL if you do not want error information.
YES if the operation is successful, otherwise NO. Returns NO if a file, directory, or symbolic link identical to path already exists.
Creates a symbolic link identified by path that refers to the location destPath in the file system.
This method does not traverse an initial symlink.
– createSymbolicLinkAtPath:pathContent:– pathContentOfSymbolicLinkAtPath:– linkPath:toPath:handler:NSFileManager.hReturns the path of the program’s current directory.
- (NSString *)currentDirectoryPath
The path of the program’s current directory. If the program’s current working directory isn’t accessible, returns nil.
The string returned by this method is initialized to the current working directory; you can change the working directory by invoking changeCurrentDirectoryPath:.
Relative pathnames refer implicitly to the current directory. For example, if the current directory is /tmp, and the relative pathname reports/info.txt is specified, the resulting full pathname is /tmp/reports/info.txt.
– changeCurrentDirectoryPath:– createDirectoryAtPath:attributes:– createDirectoryAtPath:withIntermediateDirectories:attributes:error:NSFileManager.hReturns the delegate for the receiver.
- (id)delegate
The delegate for the receiver.
NSFileManager.hReturns an NSString object containing the path of the item pointed at by the symlink specified by a given path.
- (NSString *)destinationOfSymbolicLinkAtPath:(NSString *)patherror:(NSError **)error
The path of a file or directory.
If an error occurs, upon return contains an NSError object that describes the problem. Pass NULL if you do not want error information.
An NSString object containing the path of the directory or file to which the symbolic link path refers, or nil upon failure. If the symbolic link is specified as a relative path, that relative path is returned.
This method does not traverse an initial symlink.
NSFileManager.hReturns an array of NSString objects identifying the directories and files (including symbolic links) contained in a given directory.
- (NSArray *)directoryContentsAtPath:(NSString *)path
A path to a directory.
An array of NSString objects identifying the directories and files (including symbolic links) contained in path. Returns an empty array if the directory exists but has no contents. Returns nil if the directory specified at path does not exist or there is some other error accessing it.
The search is shallow and therefore does not return the contents of any subdirectories. This returned array does not contain strings for the current directory (“.”), parent directory (“..”), or resource forks (begin with “._”) and does not traverse symbolic links.
On Mac OS X v10.5 and later, use contentsOfDirectoryAtPath:error: instead.
– contentsOfDirectoryAtPath:error:– currentDirectoryPath– fileExistsAtPath:isDirectory:– enumeratorAtPath:– subpathsAtPath:NSFileManager.hReturns the name of the file or directory at a given path in a localized form appropriate for presentation to the user.
- (NSString *)displayNameAtPath:(NSString *)path
The path of a file or directory.
The name of the file or directory at path in a localized form appropriate for presentation to the user. If there is no file or directory at path, or if an error occurs, returns [path lastPathComponent].
The returned value is localized where appropriate. For example, if you have selected French as your preferred language, the following code fragment logs “Bibliothèque”:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); |
if ([paths count] > 0) |
{ |
NSString *documentsDirectory = [paths objectAtIndex:0]; |
NSFileManager *fileManager = [NSFileManager defaultManager]; |
NSString *displayNameAtPath = [fileManager displayNameAtPath:documentsDirectory]; |
NSLog(@"%@", displayNameAtPath); |
} |
– lastPathComponent (NSString)NSFileManager.hCreates and returns an NSDirectoryEnumerator object that enumerates the contents of the directory at a given path.
- (NSDirectoryEnumerator *)enumeratorAtPath:(NSString *)path
The path of the directory to enumerate.
An NSDirectoryEnumerator object that enumerates the contents of the directory at path. If path is a symbolic link, this method evaluates the link and returns an enumerator for the file or directory the link points to. If the link cannot be evaluated, the method returns nil.
If path is a filename, the method returns an enumerator object that enumerates no files—the first call to nextObject will return nil.
Because the enumeration is deep—that is, it lists the contents of all subdirectories—this enumerator object is useful for performing actions that involve large file-system subtrees. If the method is passed a directory on which another file system is mounted (a mount point), it traverses the mount point. This method does not resolve symbolic links encountered in the traversal process, nor does it recurse through them if they point to a directory.
This code fragment enumerates the subdirectories and files under a user’s Documents directory and processes all files with an extension of .doc:
NSString *file; |
NSString *docsDir = [NSHomeDirectory() stringByAppendingPathComponent: @"Documents"]; |
NSDirectoryEnumerator *dirEnum = |
[[NSFileManager defaultManager] enumeratorAtPath:docsDir]; |
while (file = [dirEnum nextObject]) { |
if ([[file pathExtension] isEqualToString: @"doc"]) { |
[self scanDocument: [docsDir stringByAppendingPathComponent:file]]; |
} |
} |
The NSDirectoryEnumerator class has methods for obtaining the attributes of the existing path and of the parent directory and for skipping descendants of the existing path.
– currentDirectoryPath– fileAttributesAtPath:traverseLink:– directoryContentsAtPath:– subpathsAtPath:NSFileManager.hReturns a dictionary that describes the POSIX attributes of the file specified at a given.
- (NSDictionary *)fileAttributesAtPath:(NSString *)path traverseLink:(BOOL)flag
A file path.
If path is not a symbolic link, this parameter has no effect. If path is a symbolic link, then:
If YES the attributes of the linked-to file are returned, or if the link points to a nonexistent file the method returns nil.
If NO, the attributes of the symbolic link are returned.
An NSDictionary object that describes the POSIX attributes of the file specified at path. The keys in the dictionary are described in “File Attribute Keys”. If there is no item at path, returns nil.
This code example gets several attributes of a file and logs them.
NSFileManager *fileManager = [NSFileManager defaultManager]; |
NSString *path = @"/tmp/List"; |
NSDictionary *fileAttributes = [fileManager fileAttributesAtPath:path traverseLink:YES]; |
if (fileAttributes != nil) { |
NSNumber *fileSize; |
NSString *fileOwner; |
NSDate *fileModDate; |
if (fileSize = [fileAttributes objectForKey:NSFileSize]) { |
NSLog(@"File size: %qi\n", [fileSize unsignedLongLongValue]); |
} |
if (fileOwner = [fileAttributes objectForKey:NSFileOwnerAccountName]) { |
NSLog(@"Owner: %@\n", fileOwner); |
} |
if (fileModDate = [fileAttributes objectForKey:NSFileModificationDate]) { |
NSLog(@"Modification date: %@\n", fileModDate); |
} |
} |
else { |
NSLog(@"Path (%@) is invalid.", path); |
} |
As a convenience, NSDictionary provides a set of methods (declared as a category in NSFileManager.h) for quickly and efficiently obtaining attribute information from the returned dictionary: fileGroupOwnerAccountName, fileModificationDate, fileOwnerAccountName, filePosixPermissions, fileSize, fileSystemFileNumber, fileSystemNumber, and fileType. For example, you could rewrite the file modification statement in the code example above as:
if (fileModDate = [fileAttributes fileModificationDate]) |
NSLog(@"Modification date: %@\n", fileModDate); |
On Mac OS X v10.5 and later, use attributesOfItemAtPath:error: instead.
NSFileManager.hReturns a Boolean value that indicates whether a file exists at a given path.
- (BOOL)fileExistsAtPath:(NSString *)path
The path of a file or directory. If path begins with a tilde (~), it must first be expanded with stringByExpandingTildeInPath, or this method will return NO.
YES if a file specified in path exists, otherwise NO. If path specifies a symbolic link, this method traverses the link and returns YES or NO based on the existence of the file at the link destination.
NSFileManager.hReturns a Boolean value that indicates whether a specified file exists.
- (BOOL)fileExistsAtPath:(NSString *)path isDirectory:(BOOL *)isDirectory
The path of a file or directory. If path begins with a tilde (~), it must first be expanded with stringByExpandingTildeInPath, or this method will return NO.
Upon return, contains YES if path is a directory or if the final path element is a symbolic link that points to a directory, otherwise contains NO. If path doesn’t exist, the return value is undefined. Pass NULL if you do not need this information.
YES if there is a file or directory at path, otherwise NO. If path specifies a symbolic link, this method traverses the link and returns YES or NO based on the existence of the file or directory at the link destination.
If you need to further determine if path is a package, use the NSWorkspace method isFilePackageAtPath:.
This example gets an array that identifies the fonts in the user's fonts directory:
NSArray *subpaths; |
BOOL isDir; |
NSArray *paths = NSSearchPathForDirectoriesInDomains |
(NSLibraryDirectory, NSUserDomainMask, YES); |
if ([paths count] == 1) { |
NSFileManager *fileManager = [NSFileManager defaultManager]; |
NSString *fontPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Fonts"]; |
if ([fileManager fileExistsAtPath:fontPath isDirectory:&isDir] && isDir) { |
subpaths = [fileManager subpathsAtPath:fontPath]; |
// ... |
NSFileManager.hReturns a dictionary that describes the attributes of the mounted file system on which a given path resides.
- (NSDictionary *)fileSystemAttributesAtPath:(NSString *)path
Any pathname within the mounted file system.
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.
The following code example checks to see if there’s sufficient space on the file system before adding a new file to it:
NSData *contents = [myImage TIFFRepresentation]; |
NSFileManager *fileManager = [NSFileManager defaultManager]; |
NSString *path = ...; |
NSString *fileName = ...; |
NSDictionary *fsAttributes = |
[fileManager fileSystemAttributesAtPath:path]; |
if ([[fsAttributes objectForKey:NSFileSystemFreeSize] unsignedLongLongValue] > |
[contents length]) |
[fileManager createFileAtPath:[path stringByAppendingPathComponent:fileName] |
contents:contents attributes:nil]; |
On Mac OS X v10.5 and later, use attributesOfFileSystemForPath:error: instead.
– attributesOfFileSystemForPath:error:– fileAttributesAtPath:traverseLink:– changeFileAttributes:atPath:NSFileManager.hReturns a C-string representation of a given path that properly encodes Unicode strings for use by the file system.
- (const char *)fileSystemRepresentationWithPath:(NSString *)path
A file path.
A C-string representation of path that properly encodes Unicode strings for use by the file system.
If you need the C string beyond the scope of your autorelease pool, you must copy it. This method raises an exception upon error. Use this method if your code calls system routines that expect C-string path arguments.
NSFileManager.h
Returns a Boolean value that indicates whether the invoking object appears able to delete a specified file.
- (BOOL)isDeletableFileAtPath:(NSString *)path
A file path.
YES if the invoking object appears able to delete the file specified in path, otherwise NO. If the file at path does not exist, this method returns NO.
For a directory or file to be able to be deleted, either the parent directory of path must be writable or its owner must be the same as the owner of the application process. If path is a directory, every item contained in path must be able to be deleted.
This method does not traverse symbolic links.
NSFileManager.h
Returns a Boolean value that indicates whether the operating system appears able to execute a specified file.
- (BOOL)isExecutableFileAtPath:(NSString *)path
A file path.
YES if the operating system appears able to execute the file specified in path, otherwise NO. If the file at path does not exist, this method returns NO.
This method traverses symbolic links. This method uses the real user ID and group ID, as opposed to the effective user and group IDs, to determine if the file is executable.
NSFileManager.h
Returns a Boolean value that indicates whether the invoking object appears able to read a specified file.
- (BOOL)isReadableFileAtPath:(NSString *)path
A file path.
YES if the invoking object appears able to read the file specified in path, otherwise NO. If the file at path does not exist, this method returns NO.
This method traverses symbolic links. This method uses the real user ID and group ID, as opposed to the effective user and group IDs, to determine if the file is readable.
NSFileManager.h
Returns a Boolean value that indicates whether the invoking object appears able to write to a specified file.
- (BOOL)isWritableFileAtPath:(NSString *)path
A file path.
YES if the invoking object appears able to write to the file specified in path, otherwise NO. If the file at path does not exist, this method returns NO.
This method traverses symbolic links. This method uses the real user ID and group ID, as opposed to the effective user and group IDs, to determine if the file is writable.
NSFileManager.hCreates a link from a source to a destination.
- (BOOL)linkItemAtPath:(NSString *)srcPathtoPath:(NSString *)dstPatherror:(NSError **)error
A path that identifies a source file or directory.
The file, link, or directory specified by srcPath must exist.