-
Notifications
You must be signed in to change notification settings - Fork 176
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
Can't remove readonly files on Windows, is it supported? #121
Comments
attr &= ~FILE_ATTRIBUTE_READONLY; It can work when add this code in ghc::filesystem::remove() |
GHC_INLINE bool remove(const path& p, std::error_code& ec) noexcept
#else |
Thank you for reporting this. The current behavior is consistent with that of the official implementation from Microsoft, but it looks like this is listed as a Bug there too: microsoft/STL#1511 for about half a year and the PR that tries to fix it is open since beginning of this year. I'm not sure how I want to tackle this, so I need to look into this more deeply. Thanks also, for suggesting a fix, but it comes at the price slowing down all deletions, even of non-readonly files and I have scenarios where hundreds of thousands of files are been deleted, so I would prefer to maybe solve it by reacting on the deletion not succeeding and retry with changed attributes. I'll look into it. |
In the end I followed your suggestion with some additional error handling. Thank you for the prepared work! I'll try to optimize |
This is now part of release v1.5.6 |
Describe the bug
Can't remove readonly files on Windows.
To Reproduce
Create an txt file and change the property to readonly, then use ghc::filesystem::remove() to delete this file, it can't be deleted.
Expected behavior
A clear and concise description of what you expected to happen.
Additional context
The text was updated successfully, but these errors were encountered: