Common/FileSystem: Add EnsureDirectoryExists()

This commit is contained in:
Connor McLaughlin 2022-02-20 16:44:08 +10:00 committed by refractionpcsx2
parent d6f1291c0b
commit ed9f34de5f
2 changed files with 13 additions and 0 deletions

View File

@ -565,6 +565,15 @@ bool FileSystem::WriteFileToString(const char* filename, const std::string_view&
return true;
}
bool FileSystem::EnsureDirectoryExists(const char* path, bool recursive)
{
if (FileSystem::DirectoryExists(path))
return true;
// if it fails to create, we're not going to be able to use it anyway
return FileSystem::CreateDirectoryPath(path, recursive);
}
#ifdef _WIN32
static u32 TranslateWin32Attributes(u32 Win32Attributes)

View File

@ -150,6 +150,10 @@ namespace FileSystem
/// if they do not exist.
bool CreateDirectoryPath(const char* path, bool recursive);
/// Creates a directory if it doesn't already exist.
/// Returns false if it does not exist and creation failed.
bool EnsureDirectoryExists(const char* path, bool recursive);
/// Returns the path to the current executable.
std::string GetProgramPath();