Skip to content

Commit

Permalink
Config: Add cache folder
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek authored and refractionpcsx2 committed Dec 12, 2021
1 parent 38e288e commit 112238f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -79,6 +79,7 @@ oprofile_data/
/bin/PCSX2-linux.sh
/bin/GS*.txt
/bin/bios
/bin/cache
/bin/dumps
/bin/help
/bin/inis
Expand Down
1 change: 1 addition & 0 deletions pcsx2/Config.h
Expand Up @@ -628,6 +628,7 @@ namespace EmuFolders
extern wxDirName Cheats;
extern wxDirName CheatsWS;
extern wxDirName Resources;
extern wxDirName Cache;
} // namespace EmuFolders

/////////////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions pcsx2/PathDefs.h
Expand Up @@ -35,6 +35,7 @@ enum FoldersEnum_t

FolderId_Cheats,
FolderId_CheatsWS,
FolderId_Cache,

FolderId_COUNT
};
Expand Down
1 change: 1 addition & 0 deletions pcsx2/Pcsx2Config.cpp
Expand Up @@ -41,6 +41,7 @@ namespace EmuFolders
wxDirName Cheats;
wxDirName CheatsWS;
wxDirName Resources;
wxDirName Cache;
} // namespace EmuFolders

void TraceLogFilters::LoadSave(SettingsWrapper& wrap)
Expand Down
30 changes: 30 additions & 0 deletions pcsx2/gui/AppConfig.cpp
Expand Up @@ -108,6 +108,12 @@ namespace PathDefs
static const wxDirName retval(L"resources");
return retval;
}

const wxDirName& Cache()
{
static const wxDirName retval(L"cache");
return retval;
}
};

// Specifies the root folder for the application install.
Expand Down Expand Up @@ -254,6 +260,11 @@ namespace PathDefs
#endif
}

wxDirName GetCache()
{
return GetDocuments() + Base::Cache();
}

wxDirName Get(FoldersEnum_t folderidx)
{
switch (folderidx)
Expand All @@ -276,6 +287,8 @@ namespace PathDefs
return GetCheats();
case FolderId_CheatsWS:
return GetCheatsWS();
case FolderId_Cache:
return GetCache();

case FolderId_Documents:
return CustomDocumentsFolder;
Expand Down Expand Up @@ -389,6 +402,8 @@ wxDirName& AppConfig::FolderOptions::operator[](FoldersEnum_t folderidx)
return Cheats;
case FolderId_CheatsWS:
return CheatsWS;
case FolderId_Cache:
return Cache;

case FolderId_Documents:
return CustomDocumentsFolder;
Expand Down Expand Up @@ -425,6 +440,8 @@ bool AppConfig::FolderOptions::IsDefault(FoldersEnum_t folderidx) const
return UseDefaultCheats;
case FolderId_CheatsWS:
return UseDefaultCheatsWS;
case FolderId_Cache:
return UseDefaultCache;

case FolderId_Documents:
return false;
Expand Down Expand Up @@ -496,6 +513,13 @@ void AppConfig::FolderOptions::Set(FoldersEnum_t folderidx, const wxString& src,
EmuFolders::CheatsWS = GetResolvedFolder(FolderId_CheatsWS);
break;

case FolderId_Cache:
Cache = src;
UseDefaultCache = useDefault;
EmuFolders::Cache = GetResolvedFolder(FolderId_Cache);
EmuFolders::Cache.Mkdir();
break;

jNO_DEFAULT
}
}
Expand Down Expand Up @@ -703,6 +727,7 @@ AppConfig::FolderOptions::FolderOptions()
, Cheats(PathDefs::GetCheats())
, CheatsWS(PathDefs::GetCheatsWS())
, Resources(PathDefs::GetResources())
, Cache(PathDefs::GetCache())

, RunIso(PathDefs::GetDocuments()) // raw default is always the Documents folder.
, RunELF(PathDefs::GetDocuments()) // raw default is always the Documents folder.
Expand Down Expand Up @@ -741,6 +766,7 @@ void AppConfig::FolderOptions::LoadSave(IniInterface& ini)
IniEntryDirFile(Langs, rel);
IniEntryDirFile(Cheats, rel);
IniEntryDirFile(CheatsWS, rel);
IniEntryDirFile(Cache, rel);

IniEntryDirFile(RunIso, rel);
IniEntryDirFile(RunELF, rel);
Expand Down Expand Up @@ -769,6 +795,10 @@ void AppSetEmuFolders()
EmuFolders::Cheats = GetResolvedFolder(FolderId_Cheats);
EmuFolders::CheatsWS = GetResolvedFolder(FolderId_CheatsWS);
EmuFolders::Resources = g_Conf->Folders.Resources;
EmuFolders::Cache = GetResolvedFolder(FolderId_Cache);

// Ensure cache directory exists, since we're going to write to it (e.g. game database)
EmuFolders::Cache.Mkdir();
}

// ------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions pcsx2/gui/AppConfig.h
Expand Up @@ -127,7 +127,8 @@ class AppConfig
UseDefaultLogs:1,
UseDefaultLangs:1,
UseDefaultCheats:1,
UseDefaultCheatsWS:1;
UseDefaultCheatsWS:1,
UseDefaultCache:1;
BITFIELD_END

wxDirName
Expand All @@ -139,7 +140,8 @@ class AppConfig
Logs,
Cheats,
CheatsWS,
Resources;
Resources,
Cache;

wxDirName RunIso; // last used location for Iso loading.
wxDirName RunELF; // last used location for ELF loading.
Expand Down

0 comments on commit 112238f

Please sign in to comment.