Closed Bug 101527 Opened 23 years ago Closed 23 years ago

moveTo function on windows doesn't remove old directory (works on mac, linux)

Categories

(Core :: XPCOM, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.0

People

(Reporter: dougt, Assigned: sspitzer)

References

Details

(Whiteboard: [fixed on both branch and trunk])

Attachments

(2 files, 3 obsolete files)

Shane Caraveo wrote: > Seems I cannot rename directories with the moveTo function on Windows > (haven't tried other platforms), it copies the directory tree instead. > Renaming files works fine. Here is sample code to repro via xpcshell. > Thought I would get comments before posting a bug report. > Thanks > Shane Caraveo > ActiveState > > > var file = > Components.classes["@mozilla.org/file/local;1"].createInstance(Components.in > terfaces.nsILocalFile); > > // assumes test.txt exists already > // this WORKS > var fname = "c:\\temp\\test.txt"; > var newfname = "c:\\temp\\test2.txt"; > > file.initWithUnicodePath(fname); > file.moveToUnicode(null, newfname); > > // assumes that c:\temp\test directory exists already > // FAILES to rename directory, COPIES it instead, along with > files/subdirectories > var path = "c:\\temp\\test"; > var newname = "c:\\temp\\testing"; > file.initWithUnicodePath(path); > file.moveToUnicode(null, newname); It's a bug. If newParentDir is null and newName is non-null, it's supposed to be renamed in place whether it's a file or a dir. The Mac impl does that and I'm pretty sure the Unix impl does that. So, I think the Windows impl should be fixed and the comment in the .idl should be clarified.
Yes, moveTo works fine on unix. Even across logical drives. ;-) --pete
Target Milestone: --- → mozilla0.9.7
Blocks: 43226
no fire under my feet for this. sorry.
Keywords: helpwanted
Target Milestone: mozilla0.9.7 → Future
Assign it to me Doug. I'll try to get to it for 0.9.7. The only problem i have is I don't own a windows box. Anyone want to donate or even lend me a box. ;-) --pete
The description above is not exactly the behavior I'm seeing. I've got a recent build (Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.9+) Gecko/20020307) on Win2000. When I move a directory, the old directory structure stays, but all files are moved. So the final effect is that the dir is copied to a new name, and all files are removed from the original. I'll attach a test file for xpcshell (the sample code above doesn't work for me) to show what I did. -Luke
Attached file test code for xpcshell
This is a short test for moving (renaming) a directory. It's meant to be fed to xpcshell like xpcshell> load("test.js");
What if you don't use the Unicode API's? Does it work then or same thing? I'll take this since i now have a windows box. --pete
Assignee: dougt → petejc
Status: NEW → ASSIGNED
this is a trivial patch that adds a remove() after copying all the contents of a directory. so it gets rid of the empty source directory. on my windows box this makes MoveTo do what it's supposed to. - Luke
this MoveTo() bug is blocking an adt1 bug (#137886) I'll test and drive Luke's patch in.
Attached patch updated patch against trunk (obsolete) — Splinter Review
similar patch to what luke provided, just up to date. this fixes the problem for me.
Attachment #73592 - Attachment is obsolete: true
taking, and moving in, since I have an immediate need for this.
Assignee: petejc → sspitzer
Status: ASSIGNED → NEW
Target Milestone: Future → mozilla1.0
accepting.
Status: NEW → ASSIGNED
Keywords: helpwanted
Summary: cannot rename directories with the moveTo function on Windows → moveTo function on windows doesn't remove old directory (works on mac, linux)
Attached patch updated patch, more comments. (obsolete) — Splinter Review
Attachment #80914 - Attachment is obsolete: true
this looks like we remove the source in both the move and copy cases, if I'm reading the diff correctly. Shouldn't we be checking move?
Attachment #80959 - Attachment is obsolete: true
Comment on attachment 80966 [details] [diff] [review] whoops, only do the remove on move, thanks bienvenu sr=bienvenu
Attachment #80966 - Flags: superreview+
Comment on attachment 80966 [details] [diff] [review] whoops, only do the remove on move, thanks bienvenu r=dougt
Attachment #80966 - Flags: review+
fixed on the trunk. I'll seek driver approval for the branch.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Comment on attachment 80966 [details] [diff] [review] whoops, only do the remove on move, thanks bienvenu a=asa (on behalf of drivers) for checkin to the 1.0 branch
Attachment #80966 - Flags: approval+
fixed on both branch and trunk.
Whiteboard: [fixed on both branch and trunk]
adding fixed1.0.0 keyword (branch resolution). This bug has comments saying it was fixed on the 1.0 branch and a bonsai checkin comment that agrees. To verify the bug has been fixed on the 1.0 branch please replace the fixed1.0.0 keyword with verified1.0.0.
Keywords: fixed1.0.0
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: