From d08372153cf1479dff11995af56070ff2a52f71d Mon Sep 17 00:00:00 2001 From: SulfurNitride Date: Mon, 2 Mar 2026 16:42:02 -0600 Subject: Restore game directory permissions after each run In rare cases (crashes, unclean Wine shutdown), game files can end up read-only. As a precaution, restore owner rwx permissions on all files in the game directory after every run, right after FUSE unmount. Co-Authored-By: Claude Opus 4.6 --- src/src/organizercore.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/src/organizercore.cpp b/src/src/organizercore.cpp index 6e95d7e..b7878ce 100644 --- a/src/src/organizercore.cpp +++ b/src/src/organizercore.cpp @@ -47,6 +47,7 @@ #include #endif +#include #include #include #include @@ -2337,6 +2338,22 @@ void OrganizerCore::afterRun(const QFileInfo& binary, DWORD exitCode) // USVFS is only active while a hooked process is running. m_USVFS.unmount(); + // Restore write permissions on the game directory. In rare cases + // (crashes, unclean Wine shutdown) file permissions can be changed to + // read-only, preventing subsequent launches from working. + { + const QString gameDir = managedGame()->gameDirectory().absolutePath(); + namespace fs = std::filesystem; + std::error_code ec; + for (auto it = fs::recursive_directory_iterator( + gameDir.toStdString(), fs::directory_options::skip_permission_denied); + it != fs::recursive_directory_iterator(); ++it) { + fs::permissions(it->path(), + fs::perms::owner_read | fs::perms::owner_write | fs::perms::owner_exec, + fs::perm_options::add, ec); + } + } + if (m_CurrentProfile != nullptr) { const QString prefixPathStr = resolveWinePrefixPath(m_Settings, managedGame()); if (!prefixPathStr.isEmpty()) { -- cgit v1.3.1