From a9fa38c88ba4031674f02dc0a2fcf72ea0cb8e09 Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Thu, 9 Apr 2020 09:52:57 -0400 Subject: [PATCH] filesystem: use std for IsFolder Remove custom platform implementation of IsFolder and replace single use with `std::filesystem::is_directory`. --- src/xenia/base/filesystem.h | 3 --- src/xenia/base/filesystem_posix.cc | 8 -------- src/xenia/base/filesystem_win.cc | 6 ------ src/xenia/vfs/devices/stfs_container_device.cc | 2 +- 4 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/xenia/base/filesystem.h b/src/xenia/base/filesystem.h index 29d144294..90a314b45 100644 --- a/src/xenia/base/filesystem.h +++ b/src/xenia/base/filesystem.h @@ -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); diff --git a/src/xenia/base/filesystem_posix.cc b/src/xenia/base/filesystem_posix.cc index 41e317ec4..7f19332a7 100644 --- a/src/xenia/base/filesystem_posix.cc +++ b/src/xenia/base/filesystem_posix.cc @@ -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) { diff --git a/src/xenia/base/filesystem_win.cc b/src/xenia/base/filesystem_win.cc index c2cf6d54a..3242583fb 100644 --- a/src/xenia/base/filesystem_win.cc +++ b/src/xenia/base/filesystem_win.cc @@ -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); diff --git a/src/xenia/vfs/devices/stfs_container_device.cc b/src/xenia/vfs/devices/stfs_container_device.cc index 6bc3b0e22..f3aea474d 100644 --- a/src/xenia/vfs/devices/stfs_container_device.cc +++ b/src/xenia/vfs/devices/stfs_container_device.cc @@ -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;