Skip to content

Conversation

Damglador
Copy link
Contributor

@Damglador Damglador commented Oct 7, 2025

Closes #1909
Use the following directories for data storage:

  • %APPDATA%/Cubyz on Windows (~/AppData/Roaming/Cubyz)
  • $XDG_DATA_HOME/Cubyz on Linux (~/.local/share/cubyz)
  • ~/Library/Application Support/Cubyz on MacOS

If old directories are found (~/Saved Games/Cubyz or ~/.cubyz) - move them to the new location.

On Linux it also does some additional checks for XDG_DATA_HOME, because it might or might not exist, usual Linux things.

Tested this on Arch Linux and Wine.

@OneAvargeCoder193
Copy link
Contributor

Instead of just using them, it should instead transfer them over to the new directory, so that we can remove them in the next release

@Damglador
Copy link
Contributor Author

Reasonable. I'll do that tomorrow.

@IntegratedQuantum
Copy link
Member

Do you have any official source that states that it should be in %appdata% on windows? From what I've seen there are at least 4 different conventions on windows, so I took the one that seemed most reasonable.

@IntegratedQuantum
Copy link
Member

Also that's a lot of lines compared to before.

@Damglador
Copy link
Contributor Author

All apps store data somewhere in %USERPROFILE%/AppData/, Unity in LocalLow, Minecraft in Roaming, some in Local, but I don't have examples for that one. References that I managed to find:

So from my understanding, Roaming is the important data you want to have synced between devices, which game saves imo are. Though there's also an option of %localappdata%.

I'm working on cleaning up that code a bit. But I'll still be longer than the original because of backwards compatibility checks. Without them, it's only ~19 additional lines.

@IntegratedQuantum
Copy link
Member

That second link seems to imply that this is not the up to date way to store data.
Screenshot at 2025-10-08 18-15-06

@Damglador
Copy link
Contributor Author

Damglador commented Oct 8, 2025

I believe it refers not to the location itself, but to some function on Windows that synced the folder.

It links to a page that says

Package State Roaming (PSR)

PSR will be removed in a future update. PSR allows non-Microsoft developers to access roaming data on devices, enabling developers of UWP applications to write data to Windows and synchronize it to other instantiations of Windows for that user.

The recommended replacement for PSR is Azure App Service. Azure App Service is widely supported, well documented, reliable, and supports cross-platform/cross-ecosystem scenarios such as iOS, Android and web.

PSR was removed in Windows 11.

I might be a dummy and the second link might be referring to a completely different Roaming and is not related to the folders at all.

But I'm open to changing it to %localappdata%, if that's needed.

@IntegratedQuantum
Copy link
Member

Honestly none of the links are very convincing.
Second one explicitly states "Don't roam large sets of app data."
Last one is github repo with 0 stars.

@Damglador
Copy link
Contributor Author

I couldn't find any documentation for them. I remember seeing a stack overflow answer that explained them, but I won't be able to find it. I can only say that pretty much all apps and games store their data on either Roaming, Local or LocalLow, I honestly don't have a preference for any of them, as long as it's not directly in %USERPROFILE% or Documents.

@Damglador Damglador marked this pull request as draft October 8, 2025 16:51
@Damglador
Copy link
Contributor Author

Should I also add MacOS storage locations? It has its own standard, if the game is going to be ported to MacOS, it would be nice to comply with them.

Respective docs: https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html

@SpellDigger
Copy link

how about u just put a Saves folder in the root directory of the game instead :mood:

@IntegratedQuantum
Copy link
Member

That makes updating the game difficult for the player. And it also makes it harder to share settings and worlds between different versions (which is really useful in development).

@Damglador
Copy link
Contributor Author

Changes:

  • Name data folder Cubyz on all OSes
  • Use ~/Library/Application Support/Cubyz on MacOS
  • Automatically move old data to the new location (implementation is dirty, but if it's temporary, so I hope it's fine).
    If the old data location doesn't exist or the new one is already present, it does nothing.

Tested in Wine and on Arch Linux.

When the moving of old data is no longer needed, dirExists(), moveLegacyData() and all their references should be removed.

@Damglador Damglador marked this pull request as ready for review October 8, 2025 20:30
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.

Use XDG Base Directory Specification for data directories on Linux

4 participants