Instance Method

directoryContentsAtPath:

Returns the directories and files (including symbolic links) contained in a given directory.

Declaration

- (NSArray *)directoryContentsAtPath:(NSString *)path;

Parameters

path

A path to a directory.

Return Value

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.

Discussion

The search is shallow, and therefore does not return the contents of any subdirectories and does not traverse symbolic links in the specified directory. This returned array does not contain strings for the current directory (“.”), parent directory (“..”), or resource forks (begin with “._”).

Special Considerations

Because this method does not return error information, it has been deprecated as of OS X v10.5. Use contentsOfDirectoryAtPath:error: instead.

See Also

Related Symbols

currentDirectoryPath

The path to the program’s current directory.

- fileExistsAtPath:isDirectory:

Returns a Boolean value that indicates whether a file or directory exists at a specified path. The isDirectory out parameter indicates whether the path points to a directory or a regular file.

- subpathsAtPath:

Returns an array of strings identifying the paths for all items in the specified directory.

- contentsOfDirectoryAtPath:error:

Performs a shallow search of the specified directory and returns the paths of any contained items.

- enumeratorAtPath:

Returns a directory enumerator object that can be used to perform a deep enumeration of the directory at the specified path.