filesystem: use std for IsFolder

Remove custom platform implementation of IsFolder and replace
single use with `std::filesystem::is_directory`.
This commit is contained in:
Sandy Carter 2020-04-09 09:52:57 -04:00 committed by Rick Gibbed
parent 05a62673f7
commit a9fa38c88b
4 changed files with 1 additions and 18 deletions

View File

@ -52,9 +52,6 @@ bool CreateFolder(const std::filesystem::path& path);
// Returns true if the path was found and removed.
bool DeleteFolder(const std::filesystem::path& path);
// Returns true if the given path exists and is a folder.
bool IsFolder(const std::filesystem::path& path);
// Creates an empty file at the given path.
bool CreateFile(const std::filesystem::path& path);

View File

@ -137,14 +137,6 @@ static uint64_t convertUnixtimeToWinFiletime(time_t unixtime) {
return filetime;
}
bool IsFolder(const std::filesystem::path& path) {
struct stat st;
if (stat(path.c_str(), &st) == 0) {
if (S_ISDIR(st.st_mode)) return true;
}
return false;
}
bool CreateFile(const std::filesystem::path& path) {
int file = creat(path.c_str(), 0774);
if (file >= 0) {

View File

@ -84,12 +84,6 @@ bool DeleteFolder(const std::filesystem::path& path) {
return SHFileOperation(&op) == 0;
}
bool IsFolder(const std::filesystem::path& path) {
DWORD attrib = GetFileAttributes(path.c_str());
return attrib != INVALID_FILE_ATTRIBUTES &&
(attrib & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY;
}
bool CreateFile(const std::filesystem::path& path) {
auto handle = CreateFileW(path.c_str(), 0, 0, nullptr, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, nullptr);

View File

@ -61,7 +61,7 @@ StfsContainerDevice::~StfsContainerDevice() = default;
bool StfsContainerDevice::Initialize() {
// Resolve a valid STFS file if a directory is given.
if (filesystem::IsFolder(host_path_) && !ResolveFromFolder(host_path_)) {
if (std::filesystem::is_directory(host_path_) && !ResolveFromFolder(host_path_)) {
XELOGE("Could not resolve an STFS container given path {}",
xe::path_to_utf8(host_path_));
return false;