| 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 |
| Related sample code |
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 *)path error:(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 *)path error:(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 *)path error:(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 *)srcPath toPath:(NSString *)dstPath error:(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 *)path withIntermediateDirectories:(BOOL)createIntermediates attributes:(NSDictionary *)attributes error:(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.
If a file already exists at path, then if the file can be overwritten (subject to user privileges) it will be.
– 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 *)path withDestinationPath:(NSString *)destPath error:(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 *)path error:(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 or directory exists at a specified 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 the final element in 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 file or directory exists at a specified path.
- (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 the final element in 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 *)srcPath toPath:(NSString *)dstPath error:(NSError **)error
A path that identifies a source file.
The file or link specified by srcPath must exist. srcPath must not identify a directory.
A path that identifies a destination file or directory on the same filesystem as srcPath.
The destination should not yet exist. The destination path must end in a filename; there is no implicit adoption of the source filename.
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 link operation is successful, otherwise NO.
If pathname srcPath identifies a file, this method hard-links the file specified in dstPath to it. If srcPath is a symbolic link, this method copies it to dstPath instead of creating a hard link. Symbolic links in srcPath are not traversed.
Amongst other reasons (such as the disk being full, permissions problems, and so on), this method will fail if:
srcPath doesn't point to any file in the file system;
srcPath points to an existing symbolic link, but the symbolic link is “broken" (it doesn't in turn point to an existing regular file in the file system);
srcPath points to a directory;
The computer has more than one file system (such as extra partitions, mounted disk images, or network volumes), and srcPath and dstPath specify paths in different file systems.
– fileManager:shouldLinkItemAtPath:toPath:– fileManager:shouldProceedAfterError:linkingItemAtPath:toPath:– createSymbolicLinkAtPath:withDestinationPath:error:– copyItemAtPath:toPath:error:– moveItemAtPath:toPath:error:– linkPath:toPath:handler:NSFileManager.hCreates a link from a source to a destination.
- (BOOL)linkPath:(NSString *)source toPath:(NSString *)destination handler:(id)handler
A path that identifies a source file or directory.
The file, link, or directory specified by source must exist.
A path that identifies a destination file or directory.
The destination should not yet exist. The destination path must end in a filename; there is no implicit adoption of the source filename.
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 link operation is successful. If the operation is not successful, but the handler method fileManager:shouldProceedAfterError: returns YES, also returns YES. Otherwise returns NO.
If pathname source identifies a file, this method hard-links the file specified in destination to it. If source is a directory or symbolic link, this method copies it to destination instead of creating a hard link. Symbolic links in source are not traversed.
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 the pathname typed in a text field (documentFileField) and then links the file to the user’s Documents directory:
NSString *source = [documentFileField stringValue]; |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); |
if ([paths count] > 0) |
{ |
NSString *documentsDirectory = [paths objectAtIndex:0]; |
NSString *documentFileName = [source lastPathComponent]; |
NSString *destination = [documentsDirectory stringByAppendingPathComponent:documentFileName]; |
NSFileManager *fileManager = [NSFileManager defaultManager]; |
if ([fileManager fileExistsAtPath:source]) |
{ |
[fileManager linkPath:source toPath:destination handler:self]; |
} |
} |
– linkItemAtPath:toPath:error:– copyPath:toPath:handler:– createSymbolicLinkAtPath:pathContent:– movePath:toPath:handler:– fileManager:shouldProceedAfterError:– removeFileAtPath:handler:– fileManager:willProcessPath:NSFileManager.hMoves the directory or file specified by a given path to a different location in the file system identified by another path.
- (BOOL)moveItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath error:(NSError **)error
The path of a file or directory to move. srcPath must exist.
The path to which the file or directory at srcPath is moved. destination must not yet exist. The destination path must end in a filename; there is no implicit adoption of the source filename.
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 move operation is successful, otherwise NO.
– fileManager:shouldMoveItemAtPath:toPath:– fileManager:shouldProceedAfterError:movingItemAtPath:toPath:NSFileManager.hMoves the directory or file specified by a given path to a different location in the file system identified by another path.
- (BOOL)movePath:(NSString *)source toPath:(NSString *)destination handler:(id)handler
The path of a file or directory to move. source must exist.
The path to which source is moved. destination must not yet exist. The destination path must end in a filename; there is no implicit adoption of the source filename.
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 move operation is successful. If the operation is not successful, but the handler method fileManager:shouldProceedAfterError: returns YES, movePath:toPath:handler: also returns YES; otherwise returns NO.
If source is a file, the method creates a file at destination that holds the exact contents of the original file and then deletes the original file. If source is a directory, movePath:toPath:handler: creates a new directory at destination and recursively populates it with duplicates of the files and directories contained in source. It then deletes the old directory and its contents. Symbolic links are not traversed, however links are preserved. File or directory attributes—that is, metadata such as owner and group numbers, file permissions, and modification date—are also moved.
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.
If a failure in a move operation occurs, either the preexisting path or the new path remains intact, but not both.
– copyPath:toPath:handler:– linkPath:toPath:handler:– removeFileAtPath:handler:– fileManager:shouldProceedAfterError:– fileManager:willProcessPath:NSFileManager.hReturns the path of the directory or file that a symbolic link at a given path refers to.
- (NSString *)pathContentOfSymbolicLinkAtPath:(NSString *)path
The path of a symbolic link.
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.
On Mac OS X v10.5 and later, use destinationOfSymbolicLinkAtPath:error: instead.
NSFileManager.hDeletes the file, link, or directory (including, recursively, all subdirectories, files, and links in the directory) identified by a given path.
- (BOOL)removeFileAtPath:(NSString *)path handler:(id)handler
The path of a file, link, or directory to delete. The value must not be "." or "..".
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 deletion stops and the method automatically returns NO.
YES if the removal operation is successful. If the operation is not successful, but the handler method fileManager:shouldProceedAfterError: returns YES, also returns YES; otherwise returns NO.
This callback mechanism provided by handler 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.
Since the removal of directory contents is so thorough and final, be careful when using this method. If you specify "." or ".." for path an NSInvalidArgumentException exception is raised. This method does not traverse symbolic links.
– removeItemAtPath:error:– copyPath:toPath:handler:– linkPath:toPath:handler:– movePath:toPath:handler:– fileManager:shouldProceedAfterError:– fileManager:willProcessPath:NSFileManager.hDeletes the file, link, or directory (including, recursively, all subdirectories, files, and links in the directory) identified by a given path.
- (BOOL)removeItemAtPath:(NSString *)path error:(NSError **)error
The path of a file, link, or directory to delete. The value must not be "." or "..".
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 removal operation is successful, otherwise NO.
Since the removal of directory contents is so thorough and final, be careful when using this method. If you specify "." or ".." for path an NSInvalidArgumentException exception is raised. This method does not traverse symbolic links.
– copyItemAtPath:toPath:error:– linkItemAtPath:toPath:error:– moveItemAtPath:toPath:error:– fileManager:shouldRemoveItemAtPath:– fileManager:shouldProceedAfterError:removingItemAtPath:– removeFileAtPath:handler:NSFileManager.hSets the attributes of a given file or directory.
- (BOOL)setAttributes:(NSDictionary *)attributes ofItemAtPath:(NSString *)path error:(NSError **)error
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.
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 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.
NSFileManager.hSets the delegate for the receiver.
- (void)setDelegate:(id)delegate
The delegate for the receiver.
NSFileManager.hReturns an NSString object converted from the C-string representation of a pathname in the current file system.
- (NSString *)stringWithFileSystemRepresentation:(const char *)string length:(NSUInteger)len
A C string representation of a pathname.
The number of characters in string.
An NSString object converted from the C-string representation string with length len of a pathname in the current file system.
Use this method if your code receives paths as C strings from system routines.
NSFileManager.hReturns an array that contains (as NSString objects) the contents of the directory identified by a given path.
- (NSArray *)subpathsAtPath:(NSString *)path
The path of the directory to list.
An array that contains (as NSString objects) the contents of the directory identified by path. If path is a symbolic link, subpathsAtPath: traverses the link. Returns nil if it cannot get the device of the linked-to file.
This list of directory contents goes very deep and hence is very useful for large file-system subtrees. The method skips “.” and “..”.
This method reveals every element of the subtree at path, including the contents of file packages (such as applications, nib files, and RTFD files). This code fragment gets the contents of /System/Library/Fonts after verifying that the directory exists:
BOOL isDir=NO; |
NSArray *subpaths; |
NSString *fontPath = @"/System/Library/Fonts"; |
NSFileManager *fileManager = [NSFileManager defaultManager]; |
if ([fileManager fileExistsAtPath:fontPath isDirectory:&isDir] && isDir) |
subpaths = [fileManager subpathsAtPath:fontPath]; |
On Mac OS X v10.5 and later, use subpathsOfDirectoryAtPath:error: instead.
NSFileManager.hReturns an array that contains the filenames of the items in the directory specified by a given path and all its subdirectories recursively.
- (NSArray *)subpathsOfDirectoryAtPath:(NSString *)path error:(NSError **)error
The path of the directory to list.
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 that contains NSString objects representing the filenames of the items in the directory specified by path and all its subdirectories recursively. If path is a symbolic link, subpathsOfDirectoryAtPath:error: traverses the link. Returns nil if it cannot get the device of the linked-to file.
This list of directory contents goes very deep and hence is very useful for large file-system subtrees. The method skips “.” and “..”.
NSFileManager.hAn NSFileManager object sends this message immediately before attempting to copy to a given path.
- (BOOL)fileManager:(NSFileManager *)fileManager shouldCopyItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath
The NSFileManager object that sent this message.
The path or a file or directory that manager is about to attempt to copy.
The path or a file or directory to which manager is about to attempt to copy.
YES if the operation should proceed, otherwise NO.
You can implement this method in your delegate to monitor file operations.
NSFileManager.hAn NSFileManager object sends this message immediately before attempting to link to a given path.
- (BOOL)fileManager:(NSFileManager *)fileManager shouldLinkItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath
The NSFileManager object that sent this message.
The path or a file or directory that manager is about to attempt to link.
The path or a file or directory to which manager is about to attempt to link.
YES if the operation should proceed, otherwise NO.
You can implement this method in your delegate to monitor file operations.
NSFileManager.hAn NSFileManager object sends this message immediately before attempting to move to a given path.
- (BOOL)fileManager:(NSFileManager *)fileManager shouldMoveItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath
The NSFileManager object that sent this message.
The path or a file or directory that manager is about to attempt to move.
The path or a file or directory to which manager is about to attempt to move.
YES if the operation should proceed, otherwise NO.
You can implement this method in your delegate to monitor file operations.
NSFileManager.hAn NSFileManager object sends this message to its handler for each error it encounters when copying, moving, removing, or linking files or directories.
- (BOOL)fileManager:(NSFileManager *)manager shouldProceedAfterError:(NSDictionary *)errorInfo
The file manager that sent this message.
A dictionary that contains two or three pieces of information (all NSString objects) related to the error:
Key | Value |
|---|---|
| The path related to the error (usually the source path) |
| A description of the error |
| The destination path (not all errors) |
YES if the operation (which is often continuous within a loop) should proceed, otherwise NO.
An NSFileManager object, manager, sends this message for each error it encounters when copying, moving, removing, or linking files or directories. The return value is passed back to the invoker of copyPath:toPath:handler:, movePath:toPath:handler:, removeFileAtPath:handler:, or linkPath:toPath:handler:. If an error occurs and your handler has not implemented this method, the invoking method automatically returns NO.
The following implementation of fileManager:shouldProceedAfterError: displays the error string in an alert dialog and leaves it to the user whether to proceed or stop:
-(BOOL)fileManager:(NSFileManager *)manager |
shouldProceedAfterError:(NSDictionary *)errorInfo |
{ |
int result; |
result = NSRunAlertPanel(@"Gumby App", @"File operation error: |
%@ with file: %@", @"Proceed", @"Stop", NULL, |
[errorInfo objectForKey:@"Error"], |
[errorInfo objectForKey:@"Path"]); |
if (result == NSAlertDefaultReturn) |
return YES; |
else |
return NO; |
} |
NSFileManager.hAn NSFileManager object sends this message if an error occurs during an attempt to copy to a given path.
- (BOOL)fileManager:(NSFileManager *)fileManager shouldProceedAfterError:(NSError *)error copyingItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath
The NSFileManager object that sent this message.
The error that occurred during the attempt to copy.
The path or a file or directory that manager is attempting to copy.
The path or a file or directory to which manager is attempting to copy.
YES if the operation should proceed, otherwise NO.
You can implement this method in your delegate to monitor file operations.
NSFileManager.hAn NSFileManager object sends this message if an error occurs during an attempt to link to a given path.
- (BOOL)fileManager:(NSFileManager *)fileManager shouldProceedAfterError:(NSError *)error linkingItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath
The NSFileManager object that sent this message.
The error that occurred during the attempt to link.
The path or a file or directory that manager is attempting to link.
The path or a file or directory to which manager is attempting to link.
YES if the operation should proceed, otherwise NO.
NSFileManager.hAn NSFileManager object sends this message if an error occurs during an attempt to move to a given path.
- (BOOL)fileManager:(NSFileManager *)fileManager shouldProceedAfterError:(NSError *)error movingItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath
The NSFileManager object that sent this message.
The error that occurred during the attempt to move.
The path or a file or directory that manager is attempting to move.
The path or a file or directory to which manager is attempting to move.
YES if the operation should proceed, otherwise NO.
NSFileManager.hAn NSFileManager object sends this message if an error occurs during an attempt to delete a given path.
- (BOOL)fileManager:(NSFileManager *)fileManager shouldProceedAfterError:(NSError *)error removingItemAtPath:(NSString *)path
The NSFileManager object that sent this message.
The error that occurred during the attempt to copy.
The path or a file or directory that manager is attempting to delete.
YES if the operation should proceed, otherwise NO.
NSFileManager.hAn NSFileManager object sends this message immediately before attempting to delete an item at a given path.
- (BOOL)fileManager:(NSFileManager *)fileManager shouldRemoveItemAtPath:(NSString *)path
The NSFileManager object that sent this message.
The path or a file or directory that manager is about to attempt to delete.
YES if the operation should proceed, otherwise NO.
You can implement this method in your delegate to monitor file operations.
NSFileManager.hAn NSFileManager object sends this message to a handler immediately before attempting to move, copy, rename, or delete, or before attempting to link to a given path.
- (void)fileManager:(NSFileManager *)manager willProcessPath:(NSString *)path
The NSFileManager object that sent this message.
The path or a file or directory that manager is about to attempt to move, copy, rename, delete, or link to.
You can implement this method in your handler to monitor file operations.
NSFileManager.hThese keys access file attribute values contained in NSDictionary objects used by changeFileAttributes:atPath:, fileAttributesAtPath:traverseLink:, createDirectoryAtPath:attributes:, and createFileAtPath:contents:attributes:.
NSString *NSFileType; NSString *NSFileTypeDirectory; NSString *NSFileTypeRegular; NSString *NSFileTypeSymbolicLink; NSString *NSFileTypeSocket; NSString *NSFileTypeCharacterSpecial; NSString *NSFileTypeBlockSpecial; NSString *NSFileTypeUnknown; NSString *NSFileSize; NSString *NSFileModificationDate; NSString *NSFileReferenceCount; NSString *NSFileDeviceIdentifier; NSString *NSFileOwnerAccountName; NSString *NSFileGroupOwnerAccountName; NSString *NSFilePosixPermissions; NSString *NSFileSystemNumber; NSString *NSFileSystemFileNumber; NSString *NSFileExtensionHidden; NSString *NSFileHFSCreatorCode; NSString *NSFileHFSTypeCode; NSString *NSFileImmutable; NSString *NSFileAppendOnly; NSString *NSFileCreationDate; NSString *NSFileOwnerAccountID; NSString *NSFileGroupOwnerAccountID; NSString *NSFileBusy;
NSFileAppendOnlyThe key in a file attribute dictionary whose value indicates whether the file is read-only.
The corresponding value is an NSNumber object containing a Boolean value.
Available in Mac OS X v10.2 and later.
Declared in NSFileManager.h.
NSFileBusyThe key in a file attribute dictionary whose value indicates whether the file is busy.
The corresponding value is an NSNumber object containing a Boolean value.
Available in Mac OS X v10.4 and later.
Declared in NSFileManager.h.
NSFileCreationDateThe key in a file attribute dictionary whose value indicates the file's creation date.
The corresponding value is an NSDate object.
Available in Mac OS X v10.2 and later.
Declared in NSFileManager.h.
NSFileOwnerAccountNameThe key in a file attribute dictionary whose value indicates the name of the file's owner.
The corresponding value is an NSString object.
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileGroupOwnerAccountNameThe key in a file attribute dictionary whose value indicates the group name of the file's owner.
The corresponding value is an NSString object.
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileDeviceIdentifierThe key in a file attribute dictionary whose value indicates the identifier for the device on which the file resides.
The corresponding value is an NSNumber object containing an unsigned long.
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileExtensionHiddenThe key in a file attribute dictionary whose value indicates whether the file's extension is hidden.
The corresponding value is an NSNumber object containing a Boolean value.
Available in Mac OS X v10.1 and later.
Declared in NSFileManager.h.
NSFileGroupOwnerAccountIDThe key in a file attribute dictionary whose value indicates the file's group ID.
The corresponding value is an NSNumber object containing an unsigned long.
Available in Mac OS X v10.2 and later.
Declared in NSFileManager.h.
NSFileHFSCreatorCodeThe key in a file attribute dictionary whose value indicates the file's HFS creator code.
The corresponding value is an NSNumber object containing an unsigned long. See HFS File Types for possible values.
Available in Mac OS X v10.1 and later.
Declared in NSFileManager.h.
NSFileHFSTypeCodeThe key in a file attribute dictionary whose value indicates the file's HFS type code.
The corresponding value is an NSNumber object containing an unsigned long. See HFS File Types for possible values.
Available in Mac OS X v10.1 and later.
Declared in NSFileManager.h.
NSFileImmutableThe key in a file attribute dictionary whose value indicates whether the file is mutable.
The corresponding value is an NSNumber object containing a Boolean value.
Available in Mac OS X v10.2 and later.
Declared in NSFileManager.h.
NSFileModificationDateThe key in a file attribute dictionary whose value indicates the file's last modified date.
The corresponding value is an NSDate object.
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileOwnerAccountIDThe key in a file attribute dictionary whose value indicates the file's owner's account ID.
The corresponding value is an NSNumber object containing an unsigned long.
Available in Mac OS X v10.2 and later.
Declared in NSFileManager.h.
NSFilePosixPermissionsThe key in a file attribute dictionary whose value indicates the file's Posix permissions.
The corresponding value is an NSNumber object containing an unsigned long.
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileReferenceCountThe key in a file attribute dictionary whose value indicates the file's reference count.
The corresponding value is an NSNumber object containing an unsigned long.
The number specifies the number of hard links to a file.
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileSizeThe key in a file attribute dictionary whose value indicates the file's size in bytes.
The corresponding value is an NSNumber object containing an unsigned long long.
Important: If the file has a resource fork, the returned value does not include the size of the resource fork.
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileSystemFileNumberThe key in a file attribute dictionary whose value indicates the file's filesystem file number.
The corresponding value is an NSNumber object containing an unsigned long. The value corresponds to the value of st_ino, as returned by stat(2).
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileTypeThe key in a file attribute dictionary whose value indicates the file's type.
The corresponding value is an NSString object (see below for possible values).
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileDeviceIdentifier is used to access the identifier of a remote device.
NSFileManager.hThese strings the possible values for the NSFileType attribute key contained in the NSDictionary object returned from NSFileManager's fileAttributesAtPath:traverseLink:.
extern NSString *NSFileTypeDirectory; extern NSString *NSFileTypeRegular; extern NSString *NSFileTypeSymbolicLink; extern NSString *NSFileTypeSocket; extern NSString *NSFileTypeCharacterSpecial; extern NSString *NSFileTypeBlockSpecial; extern NSString *NSFileTypeUnknown;
NSFileTypeDirectoryDirectory
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileTypeRegularRegular file
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileTypeSymbolicLinkSymbolic link
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileTypeSocketSocket
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileTypeCharacterSpecialCharacter special file
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileTypeBlockSpecialBlock special file
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileTypeUnknownUnknown
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileManager.hKeys to access the file attribute values contained in the NSDictionary object returned from NSFileManager’s fileSystemAttributesAtPath: method.
extern NSString *NSFileSystemSize; extern NSString *NSFileSystemFreeSize; extern NSString *NSFileSystemNodes; extern NSString *NSFileSystemFreeNodes; extern NSString *NSFileSystemNumber;
NSFileSystemSizeThe key in a file system attribute dictionary whose value indicates the size of the file system.
The corresponding value is an NSNumber object that specifies the size of the file system in bytes. The value is determined by statfs().
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileSystemFreeSizeThe key in a file system attribute dictionary whose value indicates the amount of free space on the file system.
The corresponding value is an NSNumber object that specifies the amount of free space on the file system in bytes. The value is determined by statfs().
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileSystemNodesThe key in a file system attribute dictionary whose value indicates the number of nodes in the file system.
The corresponding value is an NSNumber object that specifies the number of nodes in the file system.
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileSystemFreeNodesThe key in a file system attribute dictionary dictionary whose value indicates the number of free nodes in the file system.
The corresponding value is an NSNumber object that specifies the number of free nodes in the file system.
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileSystemNumberThe key in a file system attribute dictionary dictionary whose value indicates the filesystem number of the file system.
The corresponding value is an NSNumber object that specifies the filesystem number of the file system. The value corresponds to the value of st_dev, as returned by stat(2).
Available in Mac OS X v10.0 and later.
Declared in NSFileManager.h.
NSFileManager.hSpecifies the version of the Foundation framework in which NSFileManager first supported resource forks.
#define NSFoundationVersionWithFileManagerResourceForkSupport 412
NSFoundationVersionWithFileManagerResourceForkSupportThe version of the Foundation framework in which NSFileManager first supported resource forks.
Available in Mac OS X v10.1 and later.
Declared in NSFileManager.h.
NSFileManager.h
© 2008 Apple Inc. All Rights Reserved. (Last updated: 2008-10-15)