Skip to content

Commit

Permalink
Extend build-in support for Documents and Library folders to more pla…
Browse files Browse the repository at this point in the history
…tforms (#122)

This change makes the built-in APIs for retrieving the system-provided
`Documents` and `Library` folders available on iOS and tvOS, as well as
macOS (which was already supported).
  • Loading branch information
JohnSundell authored Oct 28, 2020
1 parent 9c9d5f6 commit 671824c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
4 changes: 0 additions & 4 deletions Sources/Files.swift
Original file line number Diff line number Diff line change
Expand Up @@ -903,11 +903,7 @@ public extension Folder {
fileManager: fileManager
))
}
}
#endif

#if os(macOS)
public extension Folder {
/// The current user's Documents folder
static var documents: Folder? {
return try? .matching(.documentDirectory)
Expand Down
24 changes: 12 additions & 12 deletions Tests/FilesTests/FilesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,20 @@ class FilesTests: XCTestCase {
]
}

#if os(macOS)
extension FilesTests {
func testAccessingDocumentsFolder() {
XCTAssertNotNil(Folder.documents, "Documents folder should be available.")
}
}
#endif

#if os(iOS) || os(tvOS) || os(macOS)
extension FilesTests {
func testAccessingLibraryFolder() {
XCTAssertNotNil(Folder.library, "Library folder should be available.")
}

func testResolvingFolderMatchingSearchPath() {
performTest {
// Real file I/O
Expand Down Expand Up @@ -950,15 +962,3 @@ extension FilesTests {
}
}
#endif

#if os(macOS)
extension FilesTests {
func testAccessingDocumentFolder() {
XCTAssertNotNil(Folder.documents, "Document folder should be available.")
}

func testAccessingLibraryFolder() {
XCTAssertNotNil(Folder.library, "Library folder should be available.")
}
}
#endif

0 comments on commit 671824c

Please sign in to comment.