aboutsummaryrefslogtreecommitdiff
path: root/zencore/filesystem.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-25 21:22:27 +0200
committerStefan Boberg <[email protected]>2021-09-25 21:22:27 +0200
commitcd3386a73371e041fe7f392c8fbb890d25c670f2 (patch)
treefdef270583aa9039e56961c368d88ba1c989344c /zencore/filesystem.cpp
parentAdded TemporaryFile implementation, provides a simple abstraction around temp... (diff)
downloadzen-cd3386a73371e041fe7f392c8fbb890d25c670f2.tar.xz
zen-cd3386a73371e041fe7f392c8fbb890d25c670f2.zip
Removed some unnecessary filesystem wrapper functions which accepted wchar* arguments
Also moved some platform specific functionality into Windows conditional sections
Diffstat (limited to 'zencore/filesystem.cpp')
-rw-r--r--zencore/filesystem.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp
index 45e177aaa..f6e410ee2 100644
--- a/zencore/filesystem.cpp
+++ b/zencore/filesystem.cpp
@@ -21,6 +21,7 @@ namespace zen {
using namespace std::literals;
+#if ZEN_PLATFORM_WINDOWS
static bool
DeleteReparsePoint(const wchar_t* Path, DWORD dwReparseTag)
{
@@ -47,18 +48,6 @@ DeleteReparsePoint(const wchar_t* Path, DWORD dwReparseTag)
return false;
}
-bool
-CreateDirectories(const wchar_t* Dir)
-{
- return std::filesystem::create_directories(Dir);
-}
-
-bool
-CreateDirectories(const std::filesystem::path& Dir)
-{
- return std::filesystem::create_directories(Dir);
-}
-
// Erase all files and directories in a given directory, leaving an empty directory
// behind
@@ -137,11 +126,12 @@ WipeDirectory(const wchar_t* DirPath)
return true;
}
+#endif
bool
-DeleteDirectories(const wchar_t* DirPath)
+CreateDirectories(const std::filesystem::path& Dir)
{
- return WipeDirectory(DirPath) && RemoveDirectoryW(DirPath) == TRUE;
+ return std::filesystem::create_directories(Dir);
}
bool
@@ -151,16 +141,14 @@ CleanDirectory(const wchar_t* DirPath)
{
return WipeDirectory(DirPath);
}
- else
- {
- return CreateDirectories(DirPath);
- }
+
+ return CreateDirectories(DirPath);
}
bool
DeleteDirectories(const std::filesystem::path& Dir)
{
- return DeleteDirectories(Dir.c_str());
+ return WipeDirectory(Dir.c_str()) && RemoveDirectoryW(Dir.c_str()) == TRUE;
}
bool
@@ -174,6 +162,7 @@ CleanDirectory(const std::filesystem::path& Dir)
bool
SupportsBlockRefCounting(std::filesystem::path Path)
{
+#if ZEN_PLATFORM_WINDOWS
ATL::CHandle Handle(CreateFileW(Path.c_str(),
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
@@ -200,6 +189,9 @@ SupportsBlockRefCounting(std::filesystem::path Path)
}
return true;
+#else
+ return false;
+#endif
}
bool