Skip to content

Commit

Permalink
Fix append mode through OpenCFile, fixing cheat import on scoped stor…
Browse files Browse the repository at this point in the history
…age.
  • Loading branch information
hrydgard committed Aug 14, 2021
1 parent b4361fe commit e93dc8f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Common/File/FileUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ FILE *OpenCFile(const Path &path, const char *mode) {
return nullptr;
}
return fdopen(descriptor, "rb");
} else if (!strcmp(mode, "w") || !strcmp(mode, "wb") || !strcmp(mode, "wt")) {
} else if (!strcmp(mode, "w") || !strcmp(mode, "wb") || !strcmp(mode, "wt") || !strcmp(mode, "at") || !strcmp(mode, "a")) {
// Need to be able to create the file here if it doesn't exist.
// Not exactly sure which abstractions are best, let's start simple.
if (!File::Exists(path)) {
Expand All @@ -137,7 +137,12 @@ FILE *OpenCFile(const Path &path, const char *mode) {
INFO_LOG(COMMON, "Opening '%s' for write failed", path.ToString().c_str());
return nullptr;
}
return fdopen(descriptor, "wb");
FILE *f = fdopen(descriptor, "wb");
if (!strcmp(mode, "at") || !strcmp(mode, "a")) {
// Append mode.
fseek(f, 0, SEEK_END);
}
return f;
} else {
ERROR_LOG(COMMON, "OpenCFile(%s): Mode not yet supported: %s", path.c_str(), mode);
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ void GameSettingsScreen::CreateViews() {
systemSettings->Add(new CheckBox(&g_Config.bCacheFullIsoInRam, sy->T("Cache ISO in RAM", "Cache full ISO in RAM")))->SetEnabled(!PSP_IsInited());
#endif

systemSettings->Add(new ItemHeader(sy->T("Cheats", "Cheats (experimental, see forums)")));
systemSettings->Add(new ItemHeader(sy->T("Cheats", "Cheats")));
CheckBox *enableCheats = systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, sy->T("Enable Cheats")));
enableCheats->OnClick.Add([&](UI::EventParams &) {
enableReportsCheckbox_->SetEnabled(Reporting::IsSupported());
Expand Down
1 change: 1 addition & 0 deletions UI/NativeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ bool CreateDirectoriesAndroid() {
return false;
}

File::CreateFullPath(GetSysDirectory(DIRECTORY_CHEATS));
File::CreateFullPath(GetSysDirectory(DIRECTORY_SAVEDATA));
File::CreateFullPath(GetSysDirectory(DIRECTORY_SAVESTATE));
File::CreateFullPath(GetSysDirectory(DIRECTORY_GAME));
Expand Down

0 comments on commit e93dc8f

Please sign in to comment.