diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index 6420ec9..58cc8a0 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -3118,7 +3118,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options ec = std::error_code(errno, std::system_category()); return false; } - std::shared_ptr guard_out(nullptr, [out](void*) { ::close(out); }); + std::shared_ptr guard_in(nullptr, [in](void*) { ::close(in); }); int mode = O_CREAT | O_WRONLY | O_TRUNC; if (!overwrite) { mode |= O_EXCL; @@ -3127,7 +3127,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options ec = std::error_code(errno, std::system_category()); return false; } - std::shared_ptr guard_in(nullptr, [in](void*) { ::close(in); }); + std::shared_ptr guard_out(nullptr, [out](void*) { ::close(out); }); ssize_t br, bw; while ((br = ::read(in, buffer.data(), buffer.size())) > 0) { int offset = 0;