Skip to content

Commit 83e35ba

Browse files
authored
[rcore] refactor possible data loss on FileMove() (#5682)
1 parent 22cc255 commit 83e35ba

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/rcore.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,14 +2274,16 @@ int FileCopy(const char *srcPath, const char *dstPath)
22742274
// NOTE: If dst directories do not exists they are created
22752275
int FileMove(const char *srcPath, const char *dstPath)
22762276
{
2277-
int result = 0;
2277+
int result = -1;
22782278

22792279
if (FileExists(srcPath))
22802280
{
2281-
FileCopy(srcPath, dstPath);
2282-
FileRemove(srcPath);
2281+
if (FileCopy(srcPath, dstPath) == 0)
2282+
result = FileRemove(srcPath);
2283+
else
2284+
TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to copy file to [%s]", srcPath, dstPath);
22832285
}
2284-
else result = -1;
2286+
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Source file does not exist", srcPath);
22852287

22862288
return result;
22872289
}

0 commit comments

Comments
 (0)