Skip to content

Commit 5249482

Browse files
committed
FileManager: Add missing replaceItemAt(_:withItemAt:backupItemName:options:)
- This just wraps replaceItem(at:withItemAt:backupItemName:options:)
1 parent 0074e07 commit 5249482

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

Foundation/FileManager.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,10 +1045,20 @@ open class FileManager : NSObject {
10451045
open func replaceItem(at originalItemURL: URL, withItemAt newItemURL: URL, backupItemName: String?, options: ItemReplacementOptions = []) throws -> URL? {
10461046
NSUnimplemented()
10471047
}
1048+
1049+
@available(Windows, deprecated, message: "Not yet implemented")
1050+
public func replaceItemAt(_ originalItemURL: URL, withItemAt newItemURL: URL, backupItemName: String? = nil, options: ItemReplacementOptions = []) throws -> URL? {
1051+
NSUnimplemented()
1052+
}
1053+
10481054
#else
10491055
open func replaceItem(at originalItemURL: URL, withItemAt newItemURL: URL, backupItemName: String?, options: ItemReplacementOptions = []) throws -> URL? {
10501056
return try _replaceItem(at: originalItemURL, withItemAt: newItemURL, backupItemName: backupItemName, options: options)
10511057
}
1058+
1059+
public func replaceItemAt(_ originalItemURL: URL, withItemAt newItemURL: URL, backupItemName: String? = nil, options: ItemReplacementOptions = []) throws -> URL? {
1060+
return try _replaceItem(at: originalItemURL, withItemAt: newItemURL, backupItemName: backupItemName, options: options)
1061+
}
10521062
#endif
10531063

10541064
@available(*, unavailable, message: "Returning an object through an autoreleased pointer is not supported in swift-corelibs-foundation. Use replaceItem(at:withItemAt:backupItemName:options:) instead.", renamed: "replaceItem(at:withItemAt:backupItemName:options:)")
@@ -1064,17 +1074,7 @@ open class FileManager : NSObject {
10641074

10651075
return _appendSymlinkDestination(destination, toPath: path)
10661076
}
1067-
10681077

1069-
}
1070-
1071-
extension FileManager {
1072-
public func replaceItemAt(_ originalItemURL: URL, withItemAt newItemURL: URL, backupItemName: String? = nil, options: ItemReplacementOptions = []) throws -> NSURL? {
1073-
NSUnimplemented()
1074-
}
1075-
}
1076-
1077-
extension FileManager {
10781078
open var homeDirectoryForCurrentUser: URL {
10791079
return homeDirectory(forUser: NSUserName())!
10801080
}

TestFoundation/TestFileManager.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1701,13 +1701,18 @@ VIDEOS=StopgapVideos
17011701
try runSingleTest(aIsDirectory: true, bIsDirectory: false, options: [.withoutDeletingBackupItem, .usingNewMetadataOnly])
17021702
}
17031703

1704+
print("Testing Darwin Foundation compatible replace", to: &stderr)
1705+
try testReplaceMethod { (a, b, backupItemName, options) -> URL? in
1706+
try fm.replaceItemAt(a, withItemAt: b, backupItemName: backupItemName, options: options)
1707+
}
1708+
17041709
#if !DARWIN_COMPATIBILITY_TESTS
17051710
print("note: Testing platform-specific replace implementation.", to: &stderr)
17061711
try testReplaceMethod { (a, b, backupItemName, options) -> URL? in
17071712
try fm.replaceItem(at: a, withItemAt: b, backupItemName: backupItemName, options: options)
17081713
}
17091714
#endif
1710-
1715+
17111716
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
17121717
print("note: Testing cross-platform replace implementation.", to: &stderr)
17131718
try testReplaceMethod { (a, b, backupItemName, options) -> URL? in

0 commit comments

Comments
 (0)