Comments (5)
I've added removePathForcibly
, which can remove files or directories even if they are read-only or non-existent.
from directory.
Thanks for your investigation on the original issue (got here from stack)!
To summarize (correct me if I'm wrong): removeFile
hence removeDirectoryRecursive
can't remove read-only files, even when it is possible by first clearing the read-only flag. Do you propose indeed clearing the read-only flag? That would certainly be consistent with the behavior on Unix.
https://msdn.microsoft.com/ru-ru/library/windows/desktop/aa363915(v=vs.85).aspx
from directory.
Yes, I think that clearing read-only flag when it is possible it is right behavior. I think if I need to delete file or directory recursive I don`t really care read-only file or not. Thanks.
from directory.
That would certainly be consistent with the behavior on Unix.
*nix and Windows behave differently in that on *nix the permission to delete is determined by the write-bit on the parent directory, whereas on Windows the permission to delete is determined by the attributes of the file itself. I don't believe there's a way to make this "consistent" without doing a lot of ugly hacks.
I agree that the failure to delete read-only files is kind of annoying and probably not what the user expects.
However, I'm somewhat hesitant on changing the behavior of a core function such as removeFile
. Moreover, it is currently consistent with the behavior in Python's standard library.
I could add something like removeFileForcibly
though, or maybe a helper function like setWritablePermission :: Bool -> FilePath -> IO ()
.
from directory.
I agree a bit with your hesitation; I'd propose to add mention of this issue then for removeFile
together with any addition.
Would you be open to changing removeDirectoryRecursive
to use removeFileForcibly
though, or adding a variant for that?
For the original linked issue on Stack, I think we would want a portable rm -rf
which does remove readonly files.
I suppose that at least any build tool removing directories it created (cabal-install, Shake, ...) would need the same behavior, so I think this would be useful in a common package rather than inside Stack.
Since you mention the Python standard library, I found its shutil.rmtree function: they provide a callback for handling errors on a single deletion, which could be used to change permissions and allow to resume operations.
from directory.
Related Issues (20)
- Updating the CI and the cabal file HOT 2
- makeAbsolute ~ gives wrong path HOT 2
- Release for GHC 9.6.1 HOT 3
- TMPDIR environment variable not honoured on windows HOT 2
- Feature request: createLink HOT 1
- FR: a variant of getModificationTime that works on symlinks HOT 1
- Cabal file doesn't list install-includes HOT 3
- [Feature request] A way to copy a directory with metadata (and/or recursively) HOT 5
- directory bundled with GHC-9.6 is not safe (inferred) anymore. HOT 5
- Support filepath >= 1.5.0.0 and os-string
- Support Win32 2.14 HOT 5
- canonicalizePath regressed on Windows between directory-1.3.7.1 and directory-1.3.8.0 HOT 2
- Please revise `time` dependency to `< 1.15` HOT 1
- Support filepath 1.4.300.1 HOT 4
- Builds with allow-newer unnecessarily fail HOT 1
- on Windows, copyFile makes empty source and destination files when the source file is absent HOT 8
- FR: findExecutable "" should return Nothing, like on linux HOT 4
- `directory-1.3.8.3`: relax upper bound of dependency on `base` HOT 2
- Resolve TODO regarding AFPP support for openBinaryTempFile HOT 2
- Refactor remaining code to use *at APIs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from directory.