Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy and remove_all with error_code throws #4

Closed
volcoma opened this issue Jan 1, 2019 · 4 comments
Closed

copy and remove_all with error_code throws #4

volcoma opened this issue Jan 1, 2019 · 4 comments
Assignees
Labels
bug Something isn't working medium Severity: medium
Milestone

Comments

@volcoma
Copy link

volcoma commented Jan 1, 2019

First of all - finally one working impl. Great job!

Describe the bug
copy and remove_all with error_code throws exceptions due to the error code not being propagated to the directory_iterator's constructor when iterating over the files.

        for (const directory_entry& x : directory_iterator(from)) {

    for (const directory_entry& de : directory_iterator(p)) {

shoud be

        for (const directory_entry& x : directory_iterator(from, ec)) {

    for (const directory_entry& de : directory_iterator(p, ec)) {

Expected behavior
These should not throw when using the error_code api

@gulrak gulrak added bug Something isn't working medium Severity: medium labels Jan 2, 2019
@gulrak gulrak self-assigned this Jan 2, 2019
@gulrak gulrak added this to the v1.0.6 milestone Jan 2, 2019
@gulrak
Copy link
Owner

gulrak commented Jan 2, 2019

Thank you, for the kind words, and for the bug report. Indeed I missed those, and it hides two other issues. More test code to write...

gulrak added a commit that referenced this issue Jan 2, 2019
@gulrak
Copy link
Owner

gulrak commented Jan 2, 2019

Okay, I didn't run the tests on all my platforms yet (just fixed it from a macOS machine), but the fix is not complex, so I guess it will compile and work, and I will run tests on the other systems soon.
The next regular release v1.0.6 with the fix is scheduled for the upcomming weekend.

@gulrak
Copy link
Owner

gulrak commented Jan 3, 2019

Actually even that fix is not enough. After more digging, another problem is actually using the error_code variant of directory_iterator in a range-based for loop, as it calls operator++ and that is not exception-free. Working on a fix. Need to use an explicit loop for guaranteed exception safety.

gulrak added a commit that referenced this issue Jan 3, 2019
…r_code versions of fs::copy and fs::remove_all as they are compatible with "noexcet".
@gulrak
Copy link
Owner

gulrak commented Jan 4, 2019

All tests look good.

@gulrak gulrak closed this as completed Jan 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working medium Severity: medium
Projects
None yet
Development

No branches or pull requests

2 participants