HostInterface: Create user directories on startup

This commit is contained in:
Connor McLaughlin 2020-01-24 14:51:10 +10:00
parent b4c06fdcc6
commit f6fee86f1c
2 changed files with 14 additions and 0 deletions

View File

@ -53,6 +53,7 @@ static std::string GetRelativePath(const std::string& path, const char* new_file
HostInterface::HostInterface() HostInterface::HostInterface()
{ {
SetUserDirectory(); SetUserDirectory();
CreateUserDirectorySubdirectories();
m_game_list = std::make_unique<GameList>(); m_game_list = std::make_unique<GameList>();
m_game_list->SetCacheFilename(GetGameListCacheFileName()); m_game_list->SetCacheFilename(GetGameListCacheFileName());
m_game_list->SetDatabaseFilename(GetGameListDatabaseFileName()); m_game_list->SetDatabaseFilename(GetGameListDatabaseFileName());
@ -464,6 +465,16 @@ void HostInterface::SetUserDirectory()
} }
} }
void HostInterface::CreateUserDirectorySubdirectories()
{
bool result = true;
result &= FileSystem::CreateDirectory(GetUserDirectoryRelativePath("cache").c_str(), false);
if (!result)
ReportError("Failed to create one or more user directories. This may cause issues at runtime.");
}
std::string HostInterface::GetUserDirectoryRelativePath(const char* format, ...) const std::string HostInterface::GetUserDirectoryRelativePath(const char* format, ...) const
{ {
std::va_list ap; std::va_list ap;

View File

@ -90,6 +90,9 @@ protected:
void SetUserDirectory(); void SetUserDirectory();
/// Ensures all subdirectories of the user directory are created.
void CreateUserDirectorySubdirectories();
/// Returns the path of the settings file. /// Returns the path of the settings file.
std::string GetSettingsFileName() const; std::string GetSettingsFileName() const;