From 83e35ba1706cfb2f4d404ee87be7998adbfa7842 Mon Sep 17 00:00:00 2001 From: Levent Kaya <42411502+lvntky@users.noreply.github.com> Date: Mon, 23 Mar 2026 13:30:28 +0300 Subject: [PATCH] [rcore] refactor possible data loss on FileMove() (#5682) --- src/rcore.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rcore.c b/src/rcore.c index 5cdc8aca1..c83a1c4ae 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -2274,14 +2274,16 @@ int FileCopy(const char *srcPath, const char *dstPath) // NOTE: If dst directories do not exists they are created int FileMove(const char *srcPath, const char *dstPath) { - int result = 0; + int result = -1; if (FileExists(srcPath)) { - FileCopy(srcPath, dstPath); - FileRemove(srcPath); + if (FileCopy(srcPath, dstPath) == 0) + result = FileRemove(srcPath); + else + TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to copy file to [%s]", srcPath, dstPath); } - else result = -1; + else TRACELOG(LOG_WARNING, "FILEIO: [%s] Source file does not exist", srcPath); return result; }