提交 0527cb5c 编写于 作者: F fryshorts

libobs: Fix os_safe_replace not working linux

Make sure the target file exists before attempting to create a backup.
This will allow for the function to work correctly if the target does
not yet exist.
上级 4049a5a8
...@@ -434,7 +434,7 @@ int os_rename(const char *old_path, const char *new_path) ...@@ -434,7 +434,7 @@ int os_rename(const char *old_path, const char *new_path)
int os_safe_replace(const char *target, const char *from, const char *backup) int os_safe_replace(const char *target, const char *from, const char *backup)
{ {
if (backup && rename(target, backup) != 0) if (backup && os_file_exists(target) && rename(target, backup) != 0)
return -1; return -1;
return rename(from, target); return rename(from, target);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册