mirror of
https://github.com/raysan5/raylib.git
synced 2026-03-29 20:01:59 +00:00
[rcore] refactor possible data loss on FileMove() (#5682)
This commit is contained in:
10
src/rcore.c
10
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user