Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kryoflux RAW : create any missing directories in output path #352

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

renaudguerin
Copy link

@renaudguerin renaudguerin commented Aug 20, 2023

Small quality of life improvement : when opening Kryoflux RAW files for writing, create any missing directories contained in the filename pattern.

I typically want to keep KF RAW files together in a subdirectory without having to create it manually beforehand (e.g. gw read greatgame/00.0.raw).

Note: I initially made the change at the Image class level but then realised that KF overloads the __enter__ method (and other formats might not benefit as much), so it's now in kryoflux.py only.

@renaudguerin renaudguerin changed the title Create any missing directories in output path Kryoflux RAW : create any missing directories in output path Aug 20, 2023
@keirf
Copy link
Owner

keirf commented Oct 4, 2023

I don't know if I like this or not. Is it that hard to mkdir?

@renaudguerin
Copy link
Author

renaudguerin commented Oct 4, 2023

I don't know if I like this or not. Is it that hard to mkdir?

Let's say it was enough of a recurring annoyance to make me decide to delve into the code and submit this :)

It always caught me when dealing with multiple disks or when re-reading a disk after cleaning it. I quickly edit the command line to change the destination, but forget to mkdir. Or I do have mkdir in the same command line, but now I need to edit the path in two places...

I understand the reluctance to introduce non explicit side effects in general, but arguably KF RAW is already special in the way it treats the input path as a pattern and creates multiple file destinations (in fact I didn't understand this the first time I used it and saw 160 files appear).

I can't think of any negative outcome if you also create missing directories in this pattern : when dumping full disks you'll almost always want directories to keep things tidy, and if you don't, well this patch doesn't affect you. Neither does it break anything if you already mkdir'd.

I suppose that if you made a typo, you could unintentionally end up silently creating directories instead of seeing an error, but in this corner case rmdir isn't that hard :)

@renaudguerin
Copy link
Author

I've updated this patch for your latest changes, if you wanted to take another look.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants