`copy_file()` reports success-state error code for non-regular sources · Issue #205 · gulrak/filesystem · GitHub
Skip to content

copy_file() reports success-state error code for non-regular sources #205

Description

@gulrak

copy_file() returns false for a non-regular source but may leave the supplied std::error_code clear.

The implementation first queries the source status, and when from exists but is a directory or another non-regular file type, status() succeeds and leaves tecf clear. Consequently:

std::error_code ec;
bool copied = fs::copy_file(directory, destination, ec);

returns false while ec indicates success. The throwing overload also returns false instead of throwing because it relies on the same error code.

The filesystem specification requires an error to be reported when the source is not a regular file.

Expected behavior

  • A directory source returns false and sets an appropriate error code, such as the library's portable is_a_directory error.
  • Other existing non-regular source types return false with an appropriate nonzero error.
  • The throwing overload throws filesystem_error.
  • A missing source continues to report the original lookup error.
  • No destination file is created after any rejected source.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

available on masterFix is done on master branch, issue closed on next releasebugSomething isn't workingmediumSeverity: medium

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions