forked from suyu/suyu
common/file_util: Simplify the behavior of CreateFullPath
This commit is contained in:
parent
4e94d0d53a
commit
ec8548b414
1 changed files with 3 additions and 9 deletions
|
@ -136,16 +136,10 @@ bool CreateDirs(const fs::path& path) {
|
||||||
bool CreateFullPath(const fs::path& path) {
|
bool CreateFullPath(const fs::path& path) {
|
||||||
LOG_TRACE(Common_Filesystem, "path {}", path);
|
LOG_TRACE(Common_Filesystem, "path {}", path);
|
||||||
|
|
||||||
// Removes trailing slashes and turns any '\' into '/'
|
if (path.has_extension()) {
|
||||||
const auto new_path = SanitizePath(path.string(), DirectorySeparator::ForwardSlash);
|
return CreateDirs(path.parent_path());
|
||||||
|
|
||||||
if (new_path.rfind('.') == std::string::npos) {
|
|
||||||
// The path is a directory
|
|
||||||
return CreateDirs(new_path);
|
|
||||||
} else {
|
} else {
|
||||||
// The path is a file
|
return CreateDirs(path);
|
||||||
// Creates directory preceding the last '/'
|
|
||||||
return CreateDirs(new_path.substr(0, new_path.rfind('/')));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue