Allow specifying the screenshot path on the command line #3698
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.
This allow specifying a path where to save screenshots on the command line.
See pull request #3675 for another pull request that attempt this. That pull request was however incorrect with no feedback from the author since it was open. So I decided to rewrite it.
See also https://bugs.scummvm.org/ticket/13245.
There are two questions I have in this pull request:
Description of the changes
The first commit is simple and corresponds to what was done in the earlier pull request but without the bugs (and with an update to the documentation). It adds a command line option that, when used, adds a screenshotpath to the transient domain of
ConfMan
. Since the SDL backend already queriesConfMan
for this key, this just works™The other two commits are maybe more controversial and the reason why I am proposing this as a pull request instead of pushing the code directly. Since the transient domain in
ConfMan
is cleared when starting the launcher, this means that the path is only used if a game is also specified on the command line, and only until returning to the launcher. It seems to me that it would make more sense to use it even when starting with the launcher (i.e. no game is specified on the command line), and until the user quits ScummVM (so potentially for multiple games). This is what is implemented in those two commits. And this is also more or less how the--logfile=PATH
option behaves (since the log file is opened when starting ScummVM at a point where the transient domain has not yet been cleared). This however diverges from the behaviour for most other options we can pass on the command line.Handling of path separator on Windows
Also I am not completely sure how Windows handles paths with a mixture of '/' and '\'. So I was a bit cautious with my changes to the
OSystem_Win32
class in 9e9a3a7. But maybe the code could be simplified.And also if the user specifies a path that ends with a '/', it is now replaced by a '\', which was not the case before. Could that be an issue? Or is it actually better? If needed there is a simple way to get back the path as it exactly was before my changes by adding the following to
OSystem_Win32::initBackend()
after it callsOSystem_SDL::initBackend()
and removing the handling of the backslash fromOSystem_Win32::getScreenshotsPath()
:However to me this seems less clean than what I did.