mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-06-04 11:13:58 +08:00
refs #66, removed shared_ptr guards in copy_file
This commit is contained in:
parent
fd9b1c5300
commit
80543b681b
@ -3524,16 +3524,15 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options
|
|||||||
ec = detail::make_system_error();
|
ec = detail::make_system_error();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::shared_ptr<void> guard_in(nullptr, [in](void*) { ::close(in); });
|
|
||||||
int mode = O_CREAT | O_WRONLY | O_TRUNC;
|
int mode = O_CREAT | O_WRONLY | O_TRUNC;
|
||||||
if (!overwrite) {
|
if (!overwrite) {
|
||||||
mode |= O_EXCL;
|
mode |= O_EXCL;
|
||||||
}
|
}
|
||||||
if ((out = ::open(to.c_str(), mode, static_cast<int>(sf.permissions() & perms::all))) < 0) {
|
if ((out = ::open(to.c_str(), mode, static_cast<int>(sf.permissions() & perms::all))) < 0) {
|
||||||
ec = detail::make_system_error();
|
ec = detail::make_system_error();
|
||||||
|
::close(in);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::shared_ptr<void> guard_out(nullptr, [out](void*) { ::close(out); });
|
|
||||||
ssize_t br, bw;
|
ssize_t br, bw;
|
||||||
while ((br = ::read(in, buffer.data(), buffer.size())) > 0) {
|
while ((br = ::read(in, buffer.data(), buffer.size())) > 0) {
|
||||||
ssize_t offset = 0;
|
ssize_t offset = 0;
|
||||||
@ -3544,10 +3543,14 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options
|
|||||||
}
|
}
|
||||||
else if (bw < 0) {
|
else if (bw < 0) {
|
||||||
ec = detail::make_system_error();
|
ec = detail::make_system_error();
|
||||||
|
::close(in);
|
||||||
|
::close(out);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} while (br);
|
} while (br);
|
||||||
}
|
}
|
||||||
|
::close(in);
|
||||||
|
::close(out);
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user