Skip to content

Commit 934cb54

Browse files
committed
Properly check if MLC is writeable
1 parent 356cf0e commit 934cb54

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/gui/CemuApp.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ void CemuApp::InitializeExistingMLCOrFail(fs::path mlc)
234234
g_config.Save();
235235
}
236236
}
237+
else
238+
{
239+
// default path is not writeable. Just let the user know and quit. Unsure if it would be a good idea to ask the user to choose an alternative path instead
240+
wxMessageBox(formatWxString(_("Cemu failed to write to the default mlc directory.\nThe path is:\n{}"), wxHelper::FromPath(mlc)), _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
241+
exit(0);
242+
}
237243
}
238244

239245
bool CemuApp::OnInit()
@@ -507,6 +513,13 @@ bool CemuApp::CreateDefaultMLCFiles(const fs::path& mlc)
507513
file.flush();
508514
file.close();
509515
}
516+
// create a dummy file in the mlc folder to check if it's writable
517+
const auto dummyFile = fs::path(mlc).append("writetestdummy");
518+
std::ofstream file(dummyFile);
519+
if (!file.is_open())
520+
return false;
521+
file.close();
522+
fs::remove(dummyFile);
510523
}
511524
catch (const std::exception& ex)
512525
{

0 commit comments

Comments
 (0)