From 0527cb5c152317dda42c903a7b0a3f33461b39de Mon Sep 17 00:00:00 2001 From: fryshorts Date: Mon, 8 May 2017 19:24:02 +0200 Subject: [PATCH] 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. --- libobs/util/platform-nix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libobs/util/platform-nix.c b/libobs/util/platform-nix.c index 20855455e..57e8e0aec 100644 --- a/libobs/util/platform-nix.c +++ b/libobs/util/platform-nix.c @@ -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) { - if (backup && rename(target, backup) != 0) + if (backup && os_file_exists(target) && rename(target, backup) != 0) return -1; return rename(from, target); }