filesystem: use std for CreateFolder
Remove custom platform implementation of `CreateFolder` and replace uses with `std::filesystem::create_directories` which creates paths recursively.
This commit is contained in:
committed by
Rick Gibbed
parent
c8e64da4eb
commit
69bcf59c79
@@ -18,7 +18,7 @@ bool CreateParentFolder(const std::filesystem::path& path) {
|
||||
if (path.has_parent_path()) {
|
||||
auto parent_path = path.parent_path();
|
||||
if (!std::filesystem::exists(parent_path)) {
|
||||
return CreateFolder(parent_path);
|
||||
return std::filesystem::create_directories(parent_path);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -41,10 +41,6 @@ std::filesystem::path GetUserFolder();
|
||||
// attempting to create it.
|
||||
bool CreateParentFolder(const std::filesystem::path& path);
|
||||
|
||||
// Creates a folder at the specified path.
|
||||
// Returns true if the path was created.
|
||||
bool CreateFolder(const std::filesystem::path& path);
|
||||
|
||||
// Recursively deletes the files and folders at the specified path.
|
||||
// Returns true if the path was found and removed.
|
||||
bool DeleteFolder(const std::filesystem::path& path);
|
||||
|
||||
@@ -106,10 +106,6 @@ bool TruncateStdioFile(FILE* file, uint64_t length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CreateFolder(const std::filesystem::path& path) {
|
||||
return mkdir(path.c_str(), 0774);
|
||||
}
|
||||
|
||||
static int removeCallback(const char* fpath, const struct stat* sb,
|
||||
int typeflag, struct FTW* ftwbuf) {
|
||||
int rv = remove(fpath);
|
||||
|
||||
@@ -61,15 +61,6 @@ std::filesystem::path GetUserFolder() {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CreateFolder(const std::filesystem::path& path) {
|
||||
std::filesystem::path create_path;
|
||||
for (auto it = path.begin(); it != path.end(); ++it) {
|
||||
create_path /= *it;
|
||||
CreateDirectoryW(create_path.c_str(), nullptr);
|
||||
}
|
||||
return std::filesystem::exists(path);
|
||||
}
|
||||
|
||||
bool DeleteFolder(const std::filesystem::path& path) {
|
||||
auto double_null_path = path.wstring() + std::wstring(L"\0", 1);
|
||||
SHFILEOPSTRUCT op = {0};
|
||||
|
||||
Reference in New Issue
Block a user