Skip to content

Commit 50a7974

Browse files
authored
Merge pull request #1606 from spevans/pr_fm_subpaths
2 parents 627d7d8 + ddbfd91 commit 50a7974

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Foundation/FileManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ open class FileManager : NSObject {
951951
/* 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.
952952
*/
953953
open func subpaths(atPath path: String) -> [String]? {
954-
NSUnimplemented()
954+
return try? subpathsOfDirectory(atPath: path)
955955
}
956956

957957
/* 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.

TestFoundation/TestFileManager.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,13 +584,16 @@ class TestFileManager : XCTestCase {
584584
XCTAssertTrue(entries.contains("item2"))
585585
XCTAssertTrue(entries.contains("sub"))
586586
XCTAssertTrue(entries.contains("sub/item3"))
587+
XCTAssertEqual(fm.subpaths(atPath: path), entries)
587588
}
588589
catch _ {
589590
XCTFail()
590591
}
591592

592593
do {
593594
// Check a bad path fails
595+
XCTAssertNil(fm.subpaths(atPath: "/..."))
596+
594597
let _ = try fm.subpathsOfDirectory(atPath: "/...")
595598
XCTFail()
596599
}

0 commit comments

Comments
 (0)