Comment #2 by dlang-bugzilla — 2013-03-10T19:03:41Z
Is that the right thing to do, though? I'd expect the function to throw if the target exists. Doesn't help that the docs for either "copy" and "rename" do not specify what it does in that situation.
Comment #3 by andrej.mitrovich — 2013-03-10T19:14:02Z
(In reply to comment #2)
> Is that the right thing to do, though? I'd expect the function to throw if the
> target exists. Doesn't help that the docs for either "copy" and "rename" do not
> specify what it does in that situation.
Yeah I agree. If anything make the forced renaming an option, not a default behavior. That's how most tools work on win32 anyway, dunno about Posix though.
Comment #4 by andrei — 2013-03-10T19:43:21Z
No, rename must clobber. It's the only way things can be done atomically on Unix as far as I can tell. If we have code such as "if (!exists(target)) rename(source, target)" we have a race condition.
Comment #5 by dlang-bugzilla — 2013-03-10T19:53:21Z
I think a clobber option with the default set to "no" would be better. Atomicity is a valid concern, but I don't think the default behavior should imply the risk of accidentally overwriting files.
It's too late to change the behavior of "copy", and atomicity does not apply to it anyway.
Comment #6 by andrei — 2013-03-10T19:58:51Z
(In reply to comment #5)
> I think a clobber option with the default set to "no" would be better.
> Atomicity is a valid concern, but I don't think the default behavior should
> imply the risk of accidentally overwriting files.
Atomicity is not a concern as much as a gating factor. How to implement the clobber option "no" on Unix?
> It's too late to change the behavior of "copy", and atomicity does not apply to
> it anyway.
This is remove. It must clobber the target on both Windows and Unix.
Comment #7 by andrei — 2013-03-10T19:59:12Z
(In reply to comment #6)
> (In reply to comment #5)
> > I think a clobber option with the default set to "no" would be better.
> > Atomicity is a valid concern, but I don't think the default behavior should
> > imply the risk of accidentally overwriting files.
>
> Atomicity is not a concern as much as a gating factor. How to implement the
> clobber option "no" on Unix?
>
> > It's too late to change the behavior of "copy", and atomicity does not apply to
> > it anyway.
>
> This is remove. It must clobber the target on both Windows and Unix.
I mean "This is rename." :o)
Comment #8 by dlang-bugzilla — 2013-03-10T20:16:13Z
(In reply to comment #6)
> Atomicity is not a concern as much as a gating factor. How to implement the
> clobber option "no" on Unix?
Good point.
> This is rename. It must clobber the target on both Windows and Unix.
Yep, I mentioned copy earlier as they're related.
https://github.com/D-Programming-Language/phobos/pull/1198
Comment #9 by github-bugzilla — 2013-03-11T22:03:51Z