RetroArch
RetroArch copied to clipboard
When loading save file, state, and screenshot directories, attempt to…
… create them if they do not exist.
Guidelines
- Rebase before opening a pull request
- If you are sending several unrelated fixes or features, use a branch and a separate pull request for each
- If possible try squashing everything in a single commit. This is particularly beneficial in the case of feature merges since it allows easy bisecting when a problem arises
Description
In configuration.c, when checking the directory of the save state, save file, or screenshot paths either at initial program load or when applying overrides, we just fall back to a default if the directory is invalid or does not exist. This change makes it so we first attempt to create the directory with path_mkdir first. If that fails then we continue to log a warning and fall back to defaults. From my testing, path_mkdir respects filesystem permissions so we will not create a unwritable directory (it will fail and we go back to the default just like current behavior).
This will make the directory behavior more consistent since currently we do automatically create a Core or Content Directory parent folder when using the options to sort by content directory or core name.
I also updated the warning messages to tell the user where we are falling back to.
Related Issues
Could not find any
Related Pull Requests
N/A
Reviewers
[If possible @mention all the people that should review your pull request]
I'm not a fan of implicitly creating directories like this though. I think that should never be forced like this in this way, or at least not with mkdir function invocations littered all over the place.
Thank you for the feedback. Would you prefer I back out the mkdir changes and just submit the warning message changes, or is this whole PR not needed at all?
Yeah, just the warnings should be good. It's likely the installer that should set up those directories/configurations rather than the application itself.
Yeah, just the warnings should be good. It's likely the installer that should set up those directories/configurations rather than the application itself.
Thank you! I have committed your changes (I hope, this is the first time I used the Github suggestions feature which is pretty cool). I agree it makes sense for the installer to handle directory creation, but users can change it later in the configs which is why I initially wanted to try to create the path if it does not exist. To give a little more context on why I initially wanted to make a folder if it didn't exist, it was due to me noticing that if you use setup to sort screenshots (or saves) by content directory, you need to go and create each folder yourself. Like if you put your screenshots in ~/Emulators/screenshots/