aboutsummaryrefslogtreecommitdiff
path: root/src/zen/cmds/copy_cmd.cpp
diff options
context:
space:
mode:
authorzousar <[email protected]>2025-06-24 16:26:29 -0600
committerzousar <[email protected]>2025-06-24 16:26:29 -0600
commitbb298631ba35a323827dda0b8cd6158e276b5f61 (patch)
tree7ba8db91c44ce83f2c518f80f80ab14910eefa6f /src/zen/cmds/copy_cmd.cpp
parentChange to PutResult structure (diff)
parent5.6.14 (diff)
downloadarchived-zen-bb298631ba35a323827dda0b8cd6158e276b5f61.tar.xz
archived-zen-bb298631ba35a323827dda0b8cd6158e276b5f61.zip
Merge branch 'main' into zs/put-overwrite-policy
Diffstat (limited to 'src/zen/cmds/copy_cmd.cpp')
-rw-r--r--src/zen/cmds/copy_cmd.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/zen/cmds/copy_cmd.cpp b/src/zen/cmds/copy_cmd.cpp
index d42d3c107..e86b6964c 100644
--- a/src/zen/cmds/copy_cmd.cpp
+++ b/src/zen/cmds/copy_cmd.cpp
@@ -42,11 +42,8 @@ CopyCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
if (m_CopyTarget.empty())
throw std::runtime_error("No target specified");
- std::filesystem::path FromPath;
- std::filesystem::path ToPath;
-
- FromPath = m_CopySource;
- ToPath = m_CopyTarget;
+ std::filesystem::path FromPath = m_CopySource;
+ std::filesystem::path ToPath = m_CopyTarget;
std::error_code Ec;
std::filesystem::path FromCanonical = std::filesystem::canonical(FromPath, Ec);
@@ -64,8 +61,8 @@ CopyCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
}
}
- const bool IsFileCopy = std::filesystem::is_regular_file(m_CopySource);
- const bool IsDirCopy = std::filesystem::is_directory(m_CopySource);
+ const bool IsFileCopy = IsFile(m_CopySource);
+ const bool IsDirCopy = IsDir(m_CopySource);
if (!IsFileCopy && !IsDirCopy)
{
@@ -79,20 +76,14 @@ CopyCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
if (IsDirCopy)
{
- if (std::filesystem::exists(ToPath))
+ if (IsFile(ToPath))
{
- const bool IsTargetDir = std::filesystem::is_directory(ToPath);
- if (!IsTargetDir)
- {
- if (std::filesystem::is_regular_file(ToPath))
- {
- throw std::runtime_error("Attempted copy of directory into file");
- }
- }
+ throw std::runtime_error("Attempted copy of directory into file");
}
- else
+
+ if (!IsDir(ToPath))
{
- std::filesystem::create_directories(ToPath);
+ CreateDirectories(ToPath);
}
std::filesystem::path ToCanonical = std::filesystem::canonical(ToPath, Ec);
@@ -120,7 +111,11 @@ CopyCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
{
}
- virtual void VisitFile(const std::filesystem::path& Parent, const path_view& File, uint64_t FileSize, uint32_t) override
+ virtual void VisitFile(const std::filesystem::path& Parent,
+ const path_view& File,
+ uint64_t FileSize,
+ uint32_t,
+ uint64_t) override
{
ZEN_UNUSED(FileSize);
std::error_code Ec;