Repository navigation
Conversation
…copy failed Since raysan5#5920, `FileCopy()` sets `result` to 0 once the destination directory exists and never resets it, so it returns 0 when the source is missing or empty or when the destination can't be written. `FileMove()` trusts that result. If the destination is an existing file of the same size that can't be overwritten (e.g. read-only), the length check passes and the source file is removed although nothing was copied. Only return 0 from `FileCopy()` when the data was saved, and make `FileMove()` return -1 when the copied file does not check out.
raysan5
reviewed
Nov 9, 2026
| if (result != 0) TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to remove source file after copy", srcPath); | ||
| } | ||
| else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to copy file to [%s]", srcPath, dstPath); | ||
| else |
Owner
There was a problem hiding this comment.
If FileCopy() returns result == 0, this point should never be reached, why check it?
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since #5920,
FileCopy()setsresult = 0once the destination directory exists and never resets it, so it returns 0 when the source doesn't exist or is empty, or when the destination can't be written (read-only file, a directory, ...).FileMove()relies on that result and then only checks that the destination exists with the same size. When the destination is an existing read-only file of the same size, nothing is copied but the source file is removed.FileCopy()now returns 0 only when the data was saved, andFileMove()returns -1 when the copied file doesn't check out.