Browse Source

Make system::copy() overwrite destination.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
ce11ceab53
2 changed files with 2 additions and 1 deletions
  1. +1
    -0
      include/system.hpp
  2. +1
    -1
      src/system.cpp

+ 1
- 0
include/system.hpp View File

@@ -36,6 +36,7 @@ Returns whether the rename was successful.
*/ */
bool rename(const std::string& srcPath, const std::string& destPath); bool rename(const std::string& srcPath, const std::string& destPath);
/** Copies a file or directory recursively. /** Copies a file or directory recursively.
Overwrites destination if already exists.
Returns whether the copy was successful. Returns whether the copy was successful.
*/ */
bool copy(const std::string& srcPath, const std::string& destPath); bool copy(const std::string& srcPath, const std::string& destPath);


+ 1
- 1
src/system.cpp View File

@@ -136,7 +136,7 @@ bool rename(const std::string& srcPath, const std::string& destPath) {


bool copy(const std::string& srcPath, const std::string& destPath) { bool copy(const std::string& srcPath, const std::string& destPath) {
try { try {
fs::copy(fs::u8path(srcPath), fs::u8path(destPath), fs::copy_options::recursive);
fs::copy(fs::u8path(srcPath), fs::u8path(destPath), fs::copy_options::recursive | fs::copy_options::overwrite_existing);
return true; return true;
} }
catch (fs::filesystem_error& e) { catch (fs::filesystem_error& e) {


Loading…
Cancel
Save