Closed
Description
Consider the following code:
let fm = FileManager()
do {
try fm.createFile(atPath: "test", contents: nil)
try fm.linkItem(atPath: "test", toPath: "test2")
precondition(!fm.fileExists(atPath: "test3"))
try fm.copyItem(atPath: "test2", toPath: "test3")
} catch {
print("\(error)")
exit(EXIT_FAILURE)
}
Running this will produce the following filesystem contents:
E:\symlinktest>dir
...
Directory of E:\symlinktest
...
08/12/2024 02:16 PM 0 test
08/12/2024 02:16 PM <SYMLINK> test2 [test]
08/12/2024 02:16 PM 0 test3
...
AND will throw this error from copyItem:
CocoaError(code: FoundationEssentials.CocoaError.Code(rawValue: 516), userInfo: ["NSFilePath": AnyHashable("test2"), "NSUnderlyingError": AnyHashable(FoundationEssentials.Win32Error(code: 183))])
Somehow, copyItem ALWAYS fails with ERROR_ALREADY_EXISTS
when copying a symlink, even though the destination definitely did not exist prior to the call.
Swift version 6.0-dev (LLVM 31f0cdc6d5ff8a6, Swift aa0786cc7b3190c)
Microsoft Windows [Version 10.0.22631.3958]
Metadata
Assignees
Labels
No labels