From a882857262b7ddc40930a94af98eac61d9e394c3 Mon Sep 17 00:00:00 2001 From: AZero13 Date: Thu, 11 Dec 2025 10:48:41 -0500 Subject: [PATCH] GetLastError() doesn't return anything if the call succeeds Changed GetLastError() to ERROR_ALREADY_EXISTS when destination file exists check succeeds. --- Sources/FoundationEssentials/FileManager/FileOperations.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/FoundationEssentials/FileManager/FileOperations.swift b/Sources/FoundationEssentials/FileManager/FileOperations.swift index 1c28880ac..e41e3f1de 100644 --- a/Sources/FoundationEssentials/FileManager/FileOperations.swift +++ b/Sources/FoundationEssentials/FileManager/FileOperations.swift @@ -618,7 +618,7 @@ enum _FileOperations { try destination.withNTPathRepresentation { pwszDestination in var faDestinationAttributes: WIN32_FILE_ATTRIBUTE_DATA = .init() if GetFileAttributesExW(pwszDestination, GetFileExInfoStandard, &faDestinationAttributes) { - let error = CocoaError.moveFileError(GetLastError(), src, dst) + let error = CocoaError.moveFileError(ERROR_ALREADY_EXISTS, src, dst) guard fileManager._shouldProceedAfter(error: error, movingItemAtPath: source, to: destination) else { throw error }