[Issue 15102] Unified function to remove files/directories

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Oct 15 13:43:13 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=15102

--- Comment #7 from Vladimir Panteleev <thecybershadow at gmail.com> ---
(In reply to Jacob Carlborg from comment #6)
> On OS X, both Finder and Path Finder behave like this:

Try the operation that bypasses the recycle bin or equivalent.

In either case, you will be doing the deletion from a view which already
displays what type the filesystem object is (e.g. via a file/folder icon), so
the file manager will already know the object type when it's doing the
deletion.

> The only reason why you might want to have separate functions is because of
> performance reasons. But that's no reason why there can't be a unified
> function.

Performance has nothing to do with it. There are two issues:

1. Bloat. It's dumb to bloat the stdlib with functions that can be written in a
few lines of code and will be used once in a blue moon.

2. Atomicity. There is no simple way to atomically check what type an object is
and perform the corresponding operation. Between the check and the operation
the filesystem may have changed, and ugly things might happen. This is the same
reason why "rename" has no "bool overwrite" - overwriting is always on, because
that's what the OS API provides. In theory you could rename the object to an
unique name, check its type, and then do the appropriate operation, but this
sort of complicated machinations are best left for user code.

--


More information about the Digitalmars-d-bugs mailing list