Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 10, 2010 [Issue 5032] New: std.file.rename acts differently on Windows and Linux when the target file already exists. | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5032 Summary: std.file.rename acts differently on Windows and Linux when the target file already exists. Product: D Version: D2 Platform: x86 OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: lotrpy@gmail.com --- Comment #0 from lotrpy <lotrpy@gmail.com> 2010-10-09 22:30:48 PDT --- rename, on windows, if the file exists will throw a FileException. However, on Linux, it succeeds. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 09, 2011 [Issue 5032] std.file.rename acts differently on Windows and Linux when the target file already exists. | ||||
---|---|---|---|---|
| ||||
Posted in reply to lotrpy | http://d.puremagic.com/issues/show_bug.cgi?id=5032 Andrei Alexandrescu <andrei@metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |andrei@metalanguage.com AssignedTo|nobody@puremagic.com |andrei@metalanguage.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 11, 2013 [Issue 5032] std.file.rename acts differently on Windows and Linux when the target file already exists. | ||||
---|---|---|---|---|
| ||||
Posted in reply to lotrpy | http://d.puremagic.com/issues/show_bug.cgi?id=5032 --- Comment #1 from Andrei Alexandrescu <andrei@erdani.com> 2013-03-10 18:58:36 PDT --- Could somebody with access to a Windows machine change std.file.rename to overwrite the target? I see in http://msdn.microsoft.com/en-us/library/windows/desktop/aa365240(v=vs.85).aspx that MoveFileEx offers such a flag. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 11, 2013 [Issue 5032] std.file.rename acts differently on Windows and Linux when the target file already exists. | ||||
---|---|---|---|---|
| ||||
Posted in reply to lotrpy | http://d.puremagic.com/issues/show_bug.cgi?id=5032 Vladimir Panteleev <thecybershadow@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thecybershadow@gmail.com --- Comment #2 from Vladimir Panteleev <thecybershadow@gmail.com> 2013-03-11 04:03:41 EET --- 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 11, 2013 [Issue 5032] std.file.rename acts differently on Windows and Linux when the target file already exists. | ||||
---|---|---|---|---|
| ||||
Posted in reply to lotrpy | http://d.puremagic.com/issues/show_bug.cgi?id=5032 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich@gmail.com --- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-03-10 19:14:02 PDT --- (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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 11, 2013 [Issue 5032] std.file.rename acts differently on Windows and Linux when the target file already exists. | ||||
---|---|---|---|---|
| ||||
Posted in reply to lotrpy | http://d.puremagic.com/issues/show_bug.cgi?id=5032 --- Comment #4 from Andrei Alexandrescu <andrei@erdani.com> 2013-03-10 19:43:21 PDT --- 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 11, 2013 [Issue 5032] std.file.rename acts differently on Windows and Linux when the target file already exists. | ||||
---|---|---|---|---|
| ||||
Posted in reply to lotrpy | http://d.puremagic.com/issues/show_bug.cgi?id=5032 --- Comment #5 from Vladimir Panteleev <thecybershadow@gmail.com> 2013-03-11 04:53:21 EET --- 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 11, 2013 [Issue 5032] std.file.rename acts differently on Windows and Linux when the target file already exists. | ||||
---|---|---|---|---|
| ||||
Posted in reply to lotrpy | http://d.puremagic.com/issues/show_bug.cgi?id=5032 --- Comment #6 from Andrei Alexandrescu <andrei@erdani.com> 2013-03-10 19:58:51 PDT --- (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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 11, 2013 [Issue 5032] std.file.rename acts differently on Windows and Linux when the target file already exists. | ||||
---|---|---|---|---|
| ||||
Posted in reply to lotrpy | http://d.puremagic.com/issues/show_bug.cgi?id=5032 --- Comment #7 from Andrei Alexandrescu <andrei@erdani.com> 2013-03-10 19:59:12 PDT --- (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) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 11, 2013 [Issue 5032] std.file.rename acts differently on Windows and Linux when the target file already exists. | ||||
---|---|---|---|---|
| ||||
Posted in reply to lotrpy | http://d.puremagic.com/issues/show_bug.cgi?id=5032 Vladimir Panteleev <thecybershadow@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #8 from Vladimir Panteleev <thecybershadow@gmail.com> 2013-03-11 05:16:13 EET --- (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 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation