Skip to content

Unciv fails to guard against Windows filename limitations #13135

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

Closed
1 task done
SomeTroglodyte opened this issue Apr 2, 2025 · 0 comments · Fixed by #13164
Closed
1 task done

Unciv fails to guard against Windows filename limitations #13135

SomeTroglodyte opened this issue Apr 2, 2025 · 0 comments · Fixed by #13164
Assignees
Labels

Comments

@SomeTroglodyte
Copy link
Collaborator

Is there an existing issue for this?

  • I have searched the existing issues

Game Version

from current source

Describe the bug

A colon is perfectly valid in most Linux filesystem names, but not in Windows, and probably not on Linux using a M$ filesystem (remains to be tested). Same for names with trailing blanks.

Unciv does not handle that nicely, in part because the underlying libraries fail to do their job.

Steps to Reproduce

  1. Load or start a game
  2. Ctrl-S, enter "Foo : Bar" as name, save it.
  3. Try to delete that game (Now under "Foo " but you don't easily see the space) - nope
  4. Try to load that game - fails with the big popup
  5. Screen becomes less unusable because the full stack trace bloats up the error label and pushes out the right-side buttons

Screenshots

No response

Link to save file

No response

Operating System

Android

Additional Information

No particular order:

  • Windows itself still fails spectacularly for files with trailing blanks:
    * del "Foo " fails, and not everybody knows that:
    * del \\?\"<absolute-path>\Foo " is the only way (excepting third-party software) to delete such a file.
  • Writing to a file: The FileHandle still correctly contains the name "Foo : Bar", but writeString fails silently, creating a file with a different name than ordered. No exception thrown, just insubordination.
  • Reading: The FileHandle correctly shows the trailing blank, but fails actual read operations, exists or delete.
  • Gdx FileHandle.list() will return FileHandle entries whose exists() is false.
  • All this may not be the fault of Gdx or the underlying Java libraries, but it is their job to nivellate platform idiosyncracies, no?
  • Unciv trying to handle a FileNotFoundException in getLoadExceptionMessage seems pointless: Gdx wraps all exceptions in a GdxRuntimeException: see here.
  • (We would see that Exception if we replaced gameFile.readString(Charsets.UTF_8.name()) with InputStreamReader(FileInputStream(gameFile.file()), Charsets.UTF_8.name()).readText())
  • The observation in Step 5 is caused by d8b0866
  • Leading blanks work just fine, even though Windows explorer still has some difficulties (not as crass as trailing blanks though)

Before we do platform-specific file name vetting: Anybody wants to add any more observations / ideas / bad examples? (e.g. what about the syntax to access NTFS alternate streams?)

Resolution to this one-day-late April fools joke:

Oh wait the colon is the NTFS alternate streams syntax! Simplest solution is probably to guard against colons and trailing blanks over all platforms.

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

Successfully merging a pull request may close this issue.

1 participant