filesystem: use std for DeleteFolder
Remove custom platform implementation of `DeleteFolder` and replace two uses with `std::filesystem::remove_all` which removes a file or directory with all its contents.
This commit is contained in:
committed by
Rick Gibbed
parent
69bcf59c79
commit
df65de231f
@@ -41,10 +41,6 @@ std::filesystem::path GetUserFolder();
|
||||
// attempting to create it.
|
||||
bool CreateParentFolder(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);
|
||||
|
||||
// Creates an empty file at the given path.
|
||||
bool CreateFile(const std::filesystem::path& path);
|
||||
|
||||
|
||||
@@ -112,12 +112,6 @@ static int removeCallback(const char* fpath, const struct stat* sb,
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool DeleteFolder(const std::filesystem::path& path) {
|
||||
return nftw(path.c_str(), removeCallback, 64, FTW_DEPTH | FTW_PHYS) == 0
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
|
||||
static uint64_t convertUnixtimeToWinFiletime(time_t unixtime) {
|
||||
// Linux uses number of seconds since 1/1/1970, and Windows uses
|
||||
// number of nanoseconds since 1/1/1601
|
||||
|
||||
@@ -61,15 +61,6 @@ std::filesystem::path GetUserFolder() {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DeleteFolder(const std::filesystem::path& path) {
|
||||
auto double_null_path = path.wstring() + std::wstring(L"\0", 1);
|
||||
SHFILEOPSTRUCT op = {0};
|
||||
op.wFunc = FO_DELETE;
|
||||
op.pFrom = double_null_path.c_str();
|
||||
op.fFlags = FOF_NO_UI;
|
||||
return SHFileOperation(&op) == 0;
|
||||
}
|
||||
|
||||
bool CreateFile(const std::filesystem::path& path) {
|
||||
auto handle = CreateFileW(path.c_str(), 0, 0, nullptr, CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user