Improve cross-platform (particularly Linux) support with case-insensitive path handling among other things#145
Improve cross-platform (particularly Linux) support with case-insensitive path handling among other things#145xormatrix wants to merge 7 commits intoVoljega:masterfrom
Conversation
mbcs is a Windows-only encoding. Change encoding to cp1252 for better cross-platform support. Fixes Voljega#138.
* getActualFilesystemFilename(): Get the actual filename that
exists in the filesystem from a case-insensitive filename.
* getActualFilesystemPath(): Recursive version
of getActualFilesystemFilename().
These functions are necessary for better case-sensitive filesystem
support with regards to how batch files and .cue specify paths in
a case-insensitive way. We need a way to resolve these paths
regardless of case no matter the filesystem or operating system.
Extra: Improved implemenentation of localOSPath()
with the use of PurePath and PureWindowsPath.
Use the new case-insensitive path functions (util.getActualFilesystemPath() and the like) to properly resolve paths from batch files and .cue files. Improve code readability while we're at it and make some additional small changes for the sake of safety and clarity.
|
Hello, I'm ill at the moment so I'm in no mental shape to review this, but I'll get back to you as soon as I can. |
Add an option 'cached_listdir' to getActualFilesystemFilename(). This option specifies a list of filenames to search through (e.g. from os.listdir()). This is useful if you need to use getActualFilesystemFilename() multiple times in a single directory, using 'cached_listdir' then avoids excessive filesystem access operations.
Handle any discrepancies between the .csv collection cache (which maps the full game name -> game directory name) and the actual directory names in the collection config directory. Should fix Voljega#119, though further testing may be required. EXAMPLE: The eXoDOSv6.csv collection cache maps the full game name to the game directory name: * "Commander Keen - Keen Dreams (1993)" -> "CKeenDr" But what if in a new release of eXoDOS, the game directory name were changed to "ckeendr"? On a case-sensitive filesystem, the code looks for "CKeenDr" (from the collection cache) and doesn't find it, but on a case-insensitive filesystem there would be no issues (such as NTFS). To avoid any issues, resolve the game directory from the cache to its actual case-corrected filesystem name (in this case, "ckeendr") before continuing.
During game directory name resolution, remove any found game directories such that searching gets progressively faster. Tested on my computer, this speeds up the process by ~18x for eXoDOS.
|
Ran into this when trying out your changes to get around the
|
|
@v4u6h4n Sorry for the late response. I'd assume you've already figured out the issue but just in case I'll post the solution here.
But yes, the errors are a bit cryptic I agree. |
|
Hey @xormatrix :-) Thanks for the reply, the error actually occurs before the GUI spawns, so I can't change the value. I messed around with (and reverted) I did manage to just switch the encoding over to |
|
@v4u6h4n Alright it's fixed now :) It was a simple fix. Resolving the actual game directory names (with correct casing) from the collection folder is only possible if the collection folder, y'know, actually exists. Otherwise Python raises a FileNotFound error. The default is Now the code first checks if the collection folder exists, if not it send an error message asking the user to select an existing folder and also returns an empty game list. |
|
Hello again. Thanks for the help! :-) that did the trick; I can actually get it outputting something playable now. I am getting a lot of imagemount errors in dos when it first boots up, but the game does run afterwards. So I'm not sure what's going on there, I'll have a play around and see if I can get different results with different conversion types. |
Improve cross-platform compatibility and case-sensitive filesystem support. I've added two functions for resolving paths given case-insensitive paths (
getActualFilesystemFilename()andgetActualFilesystemPath()). These are necessary to deal with the case-insensitive paths in batch and.cuefiles.I've also changed the encoding used in
gamegenerator.pyfrommbcs(a Windows-only encoding) tocp1252. This fixes rezipping games for dosbox-pure in Linux.Lastly, I made some small changes and improved the code readability for the sections I changed, for the sake of safety and clarity.
There may still be some changes necessary, I've already done some testing but it's difficult to be sure, someone more experienced with the codebase must judge that.
mbcsis a Windows only encoding #138