[rcore] refactor possible data loss on FileMove()

This commit is contained in:
Levent Kaya 2026-03-22 23:15:26 +03:00
parent 1b084ff9f2
commit b888a39885

View File

@ -2274,14 +2274,16 @@ int FileCopy(const char *srcPath, const char *dstPath)
// NOTE: If dst directories do not exists they are created // NOTE: If dst directories do not exists they are created
int FileMove(const char *srcPath, const char *dstPath) int FileMove(const char *srcPath, const char *dstPath)
{ {
int result = 0; int result = -1;
if (FileExists(srcPath)) if (FileExists(srcPath))
{ {
FileCopy(srcPath, dstPath); if (FileCopy(srcPath, dstPath) == 0)
FileRemove(srcPath); 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; return result;
} }