aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/filesystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zencore/filesystem.cpp')
-rw-r--r--src/zencore/filesystem.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/zencore/filesystem.cpp b/src/zencore/filesystem.cpp
index 5125beeca..8e6f5085f 100644
--- a/src/zencore/filesystem.cpp
+++ b/src/zencore/filesystem.cpp
@@ -1290,6 +1290,27 @@ MoveToFile(std::filesystem::path Path, IoBuffer Data)
zen::CreateDirectories(Path.parent_path());
Success = SetFileInformationByHandle(ChunkFileHandle, FileRenameInfo, RenameInfo, BufferSize);
}
+ if (!Success && (LastError == ERROR_ACCESS_DENIED))
+ {
+ // Fallback to regular rename
+ std::error_code Ec;
+ std::filesystem::path SourcePath = PathFromHandle(FileRef.FileHandle, Ec);
+ if (!Ec)
+ {
+ auto NativeSourcePath = SourcePath.native().c_str();
+ auto NativeTargetPath = Path.native().c_str();
+ Success = ::MoveFile(NativeSourcePath, NativeTargetPath);
+ if (!Success)
+ {
+ LastError = GetLastError();
+ if (LastError == ERROR_PATH_NOT_FOUND)
+ {
+ zen::CreateDirectories(Path.parent_path());
+ Success = ::MoveFile(NativeSourcePath, NativeTargetPath);
+ }
+ }
+ }
+ }
}
Memory::Free(RenameInfo);
if (!Success)