mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 13:20:27 -06:00
Common/FileUtil: Add CreateDirs() function as a wrapper around std::filesystem::create_directories().
This commit is contained in:
@ -193,7 +193,6 @@ bool Delete(const std::string& filename, IfAbsentBehavior behavior)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns true if successful, or path already exists.
|
||||
bool CreateDir(const std::string& path)
|
||||
{
|
||||
DEBUG_LOG_FMT(COMMON, "{}: directory {}", __func__, path);
|
||||
@ -209,6 +208,22 @@ bool CreateDir(const std::string& path)
|
||||
return success;
|
||||
}
|
||||
|
||||
bool CreateDirs(std::string_view path)
|
||||
{
|
||||
DEBUG_LOG_FMT(COMMON, "{}: directory {}", __func__, path);
|
||||
|
||||
std::error_code error;
|
||||
auto native_path = StringToPath(path);
|
||||
bool success = fs::create_directories(native_path, error);
|
||||
// If the path was not created, check if it was a pre-existing directory
|
||||
std::error_code error_ignored;
|
||||
if (!success && fs::is_directory(native_path, error_ignored))
|
||||
success = true;
|
||||
if (!success)
|
||||
ERROR_LOG_FMT(COMMON, "{}: failed on {}: {}", __func__, path, error.message());
|
||||
return success;
|
||||
}
|
||||
|
||||
bool CreateFullPath(std::string_view fullPath)
|
||||
{
|
||||
DEBUG_LOG_FMT(COMMON, "{}: path {}", __func__, fullPath);
|
||||
|
Reference in New Issue
Block a user