libobs/util: Use MoveFileEx with MOVEFILE_REPLACE_EXISTING
Ensures that it will replace an old file if it exists.
This commit is contained in:
parent
ac2f792d50
commit
2537f9a5e2
@ -549,7 +549,8 @@ int os_rename(const char *old_path, const char *new_path)
|
||||
goto error;
|
||||
}
|
||||
|
||||
code = MoveFileW(old_path_utf16, new_path_utf16) ? 0 : -1;
|
||||
code = MoveFileExW(old_path_utf16, new_path_utf16,
|
||||
MOVEFILE_REPLACE_EXISTING) ? 0 : -1;
|
||||
|
||||
error:
|
||||
bfree(old_path_utf16);
|
||||
@ -576,7 +577,8 @@ int os_safe_replace(const char *target, const char *from, const char *backup)
|
||||
if (ReplaceFileW(wtarget, wfrom, wbackup, 0, NULL, NULL)) {
|
||||
code = 0;
|
||||
} else if (GetLastError() == ERROR_FILE_NOT_FOUND) {
|
||||
code = MoveFile(wfrom, wtarget) ? 0 : -1;
|
||||
code = MoveFileExW(wfrom, wtarget, MOVEFILE_REPLACE_EXISTING)
|
||||
? 0 : -1;
|
||||
}
|
||||
|
||||
fail:
|
||||
|
Loading…
x
Reference in New Issue
Block a user