Skip to content

Commit de64dec

Browse files
authored
Merge pull request #143 from actboy168/patch-1
Fixes skip_existing on fs::copy
2 parents 4041174 + f6d7d5b commit de64dec

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

include/ghc/filesystem.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3920,11 +3920,14 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options
39203920
ec = tecf;
39213921
return false;
39223922
}
3923-
if (exists(st) && (!is_regular_file(st) || equivalent(from, to, ec) || (options & (copy_options::skip_existing | copy_options::overwrite_existing | copy_options::update_existing)) == copy_options::none)) {
3924-
ec = tect ? tect : detail::make_error_code(detail::portable_error::exists);
3925-
return false;
3926-
}
39273923
if (exists(st)) {
3924+
if ((options & copy_options::skip_existing) == copy_options::skip_existing) {
3925+
return false;
3926+
}
3927+
if (!is_regular_file(st) || equivalent(from, to, ec) || (options & (copy_options::overwrite_existing | copy_options::update_existing)) == copy_options::none) {
3928+
ec = tect ? tect : detail::make_error_code(detail::portable_error::exists);
3929+
return false;
3930+
}
39283931
if ((options & copy_options::update_existing) == copy_options::update_existing) {
39293932
auto from_time = last_write_time(from, ec);
39303933
if (ec) {

0 commit comments

Comments
 (0)