aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--zencore/filesystem.cpp30
-rw-r--r--zencore/include/zencore/filesystem.h3
2 files changed, 11 insertions, 22 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
diff --git a/zencore/include/zencore/filesystem.h b/zencore/include/zencore/filesystem.h
index a2d368d6f..16d6ede53 100644
--- a/zencore/include/zencore/filesystem.h
+++ b/zencore/include/zencore/filesystem.h
@@ -14,19 +14,16 @@ class IoBuffer;
/** Delete directory (after deleting any contents)
*/
-ZENCORE_API bool DeleteDirectories(const wchar_t* dir);
ZENCORE_API bool DeleteDirectories(const std::filesystem::path& dir);
/** Ensure directory exists.
Will also create any required parent directories
*/
-ZENCORE_API bool CreateDirectories(const wchar_t* dir);
ZENCORE_API bool CreateDirectories(const std::filesystem::path& dir);
/** Ensure directory exists and delete contents (if any) before returning
*/
-ZENCORE_API bool CleanDirectory(const wchar_t* dir);
ZENCORE_API bool CleanDirectory(const std::filesystem::path& dir);
/** Map native file handle to a path