OS-specific file-names--where should I look?

Okay, I think that I may have found the source of the “crash at main menu” bug in the demo of A Door to the Mists: it looks like there were some places in which I neglected to apply “Filename.toOsSpecific()” when having the “os” module interact with file-names.

I’ve already searched my code for references to “os.” and updated them as called for, I believe. My question, then, is this: where else should I look for potential issues of this sort?

I think that I recall that file-names that are handled by Panda are safe, even when simply given as strings: Panda handles the conversion internally. Am I correct in that? And if so, are there other potential file-usages that I might be missing or forgetting…?

Generally, you need to worry about this with paths that are either:

  • Input by the user
  • Coming from Python, such as the os module
  • Coming from a third-party library

All paths coming from Panda should already be in Panda-specific filename format.

Conversely, you need to put paths in OS-specific format in the opposite of those three situations.

Ah, that’s reassuring, I do believe. Thank you! :slight_smile:

Addressing each of those:

  • I don’t think that I have any user-specified file-names, aside from key-binding files, and those go through GameSaver (see below).
    • Save-games are named by the game, and also go through GameSaver.
  • The os module has hopefully been taken care of. It’s possible that some other system-module is interacting with files, but if so, I’m not sure of what it might be.
  • The closest that I have to a third-party library that interacts with files, as far as I recall, is my GameSaver module.

That last does invoke one uncertainty, however: GameSaver imports Panda’s “direct”-based “file”-module, so that it replaces Python’s. Am I correct in thinking that Panda’s “file”-module is as safe as other Panda-provided elements?

Actually, since it tries to emulate Python’s file module, it expects OS-specific filenames if you pass in a regular string. However, if you pass in a Filename object, it assumes it to be a Panda filename.

Argh, that’s a pity (especially as I’ve just finished a new pair of builds)–I’d better check that, and make new builds if called for! >_<

Thank you for the answer! :slight_smile:

[edit] Phew–it looks like I was already passing OS-specific strings to GameSaver! That’s a relief! :smiley:

If there’s any testing you’d like me to do on Windows before you publish a new set of builds, let me know (or ask around on the Discord or IRC channel).

Thank you very much! I really appreciate that. :slight_smile:

I think that I very much want to get this new, (presumably) working build up sooner rather than later, however. Thus I won’t take you up on the offer this time–but do nevertheless appreciate it. :slight_smile: