Skip to content

FileManager: Implement subpaths(atPath path: String) -> [String]? #1606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Foundation/FileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ open class FileManager : NSObject {
/* subpathsAtPath: returns an NSArray of all contents and subpaths recursively from the provided path. This may be very expensive to compute for deep filesystem hierarchies, and should probably be avoided.
*/
open func subpaths(atPath path: String) -> [String]? {
NSUnimplemented()
return try? subpathsOfDirectory(atPath: path)
}

/* These methods are provided here for compatibility. The corresponding methods on NSData which return NSErrors should be regarded as the primary method of creating a file from an NSData or retrieving the contents of a file as an NSData.
Expand Down
3 changes: 3 additions & 0 deletions TestFoundation/TestFileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -584,13 +584,16 @@ class TestFileManager : XCTestCase {
XCTAssertTrue(entries.contains("item2"))
XCTAssertTrue(entries.contains("sub"))
XCTAssertTrue(entries.contains("sub/item3"))
XCTAssertEqual(fm.subpaths(atPath: path), entries)
}
catch _ {
XCTFail()
}

do {
// Check a bad path fails
XCTAssertNil(fm.subpaths(atPath: "/..."))

let _ = try fm.subpathsOfDirectory(atPath: "/...")
XCTFail()
}
Expand Down