subpathsOfDirectory(atPath:)
Performs a deep enumeration of the specified directory and returns the paths of all of the contained subdirectories.
Declaration
func subpathsOfDirectory(atPath path: String) throws -> [String]Parameters
- path:
The path of the directory to list.
Return Value
An array of strings, each containing the path of an item in the directory specified by path. When using Objective-C, returns nil if an error occurred.
Discussion
This method recurses the specified directory and its subdirectories. The method skips the “.” and “..” directories at each level of the recursion.
Because this method recurses the directory’s contents, you might not want to use it in performance-critical code. Instead, consider using the enumeratorAtURL:includingPropertiesForKeys:options:errorHandler: or enumerator(atPath:) method to enumerate the directory contents yourself. Doing so gives you more control over the retrieval of items and more opportunities to complete the enumeration or perform other tasks at the same time.
See Also
Discovering directory contents
contentsOfDirectory(at:includingPropertiesForKeys:options:)contentsOfDirectory(atPath:)enumerator(at:includingPropertiesForKeys:options:errorHandler:)enumerator(atPath:)FileManager.DirectoryEnumeratormountedVolumeURLs(includingResourceValuesForKeys:options:)FileManager.VolumeEnumerationOptionssubpaths(atPath:)