Closed Bug 70722 Opened 25 years ago Closed 23 years ago

nsILocalFile needs a recursive copy [PATCH]

Categories

(Core :: XPCOM, enhancement, P3)

All
Linux
enhancement

Tracking

()

RESOLVED FIXED
mozilla1.0.1

People

(Reporter: pete, Assigned: pete)

Details

Attachments

(7 files)

nsILocalFile needs a recursive copy --pete
Target Milestone: --- → Future
Is this a request for a feature? We need more information otherwise I am going to mark this invalid.
OS: other → Linux
Hardware: Other → All
Target Milestone: Future → ---
A request for inclusion suggested by Doug T in the new nsIFIle changes coming down the mountain. Mark invalid and i'll kick your but tough guy! ;-) --pete
Marking NEW. :)
Severity: normal → enhancement
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: nsILocalFile needs a recursive copy → [RFE] nsILocalFile needs a recursive copy
...another feature request for your back-burner, Edward. DougT suggested it, if he wants it ... perhaps he should write it :-) Consider re-assigning it to him.
Assignee: scc → kandrot
QA Contact: kandrot → scc
To set the record straight, Doug didn't suggest it, I did . . . I will be writing this shortly in as part of jslib work i am currently doing. I may as well do a c++ implementation as well while i'm at it. Assign this bug to me if you want. --pete
Sounds like you have a handle on it. Reassigning as you requested. Thanks.
Assignee: kandrot → petejc
Status: NEW → ASSIGNED
Target Milestone: --- → Future
Changing email address
Assignee: petejc → petejc
Status: ASSIGNED → NEW
Status: NEW → ASSIGNED
Yea, this is actually needed for moveTo to successfully move an entire dir and it's contents across different logical devices. Right now we can't do this (on unix anyway) . . . libc "rename" only works on the same file system. So moveTo would implement a recursive copy method and then delete the remaining original files and dirs. --pete
I have copyToRecursive() now implemented on unix. It will do a recursive copy across filesystems and can be used by moveTo() to move files across filesystems. I will have a first draft patch later today. I will need help getting this tested on other platforms. Thanks --pete
Attached file js test file —
First draft of this implementation that is tested and working on unix is in atachment #41838. I'd appreciate some feedback for initial revisions. Pot holes etc . Then after that, i can add implementations to the other platforms. --pete
Summary: [RFE] nsILocalFile needs a recursive copy → nsILocalFile needs a recursive copy [PATCH]
Keywords: patch, review
one change i can see already is, the param "dir" doesn't need to be there. it can be implemented in the CopySubDirContents method iteslf. nsresult CopySubDirContents(nsIFile *newParent, nsISimpleEnumerator *dir, PRInt32 *indx, nsISupportsArray **_retval); --pete
Is nsIFile not one of the "frozen" interfaces? Should we really be making changes to this interface?
jst, even if it is forzen. Having an implementation for post 1.0 isn't a bad idea. I will maintain the patch. Or are you suggesting create another interface for new nsIFIle methods? I'm scratching an itch here. ;-) --pete
nsIFile is not frozen - in fact, it needs lots of work. We discussed this at an arch meeting a long time ago but nothing was done. dougt wrote up what was discussed and posted it on n.p.m.xpcom and porkjockeys. I think there were some good plans. As far as this patch goes, man, it's a lot of code. I made an implementation of this here: http://lxr.mozilla.org/mozilla/source/profile/src/nsProfile.cpp#183 which I think does the same thing, is the same for all platforms, and is quite a bit smaller. Hit me for putting it where I did.
Thats alright Conrad, if implemented it in js i'm sure i would have ended up with mush less code since thats a language i'm stronger at. I needed to do this. I don't have the oportunity to implement things in c++ much. I'll work on trimming it down. But a method like this is obviously needed. So lets work on getting any implementation in! --pete
Although,this code is still a bit fatter than Conrads, the reason being that we only have one param and will try to do the right thing if the dest dir exists by appending the leaf from the current nsIFile dir. There is also a bit more error checking for dirs that are symlinks and checking to make sure the src and dest are not equal etc . . . So, i am curious to see if this compiles on the other platforms. Thanks --pete
Attached patch tweak — — Splinter Review
if (isDirectory) { - // XXXbe what's the bugzilla.mozilla.org bug number for this? - rv = NS_ERROR_NOT_IMPLEMENTED; + // XXXbe what's the bugzilla.mozilla.org bug number for this? bug=70722 --pete + rv = NS_ERROR_NOT_IMPLEMENTED; // CopyToRecursive(newParent) will be used This comment isn't right. The real bug there is bug 53474. CopyTo is currently implemented for directories (recursively) on all platforms except Unix :-( The diference between CopyTo and RecursiveCopy should be that, with RecursiveCopy, if the dest dir already exists, we should not append the leaf name and create a child - we should copy the contents of the src dir into the dest dir. If I want to copy a dir into a parent dir, I would just use CopyTo (except that it doesn't work with dirs on Unix) RecursiveCopy is useful instead of CopyTo when you have a dest dir with files in it and you want to copy the contents of a src dir into that dir, leaving the existing files in dest dir alone.
Ok, so the implementation we have here is for copyTo to copy dirs recursively on unix. So i can pull this method out of "nsIFile.idl" and it should fix bug#53474. Correct? Then we can create a recursive copy method to add to nsIFile interface. Doug? You own nsIFIle right? Any comments. I'll do what needs to be done. Lets just clarify things and get it done. Thanks --pete
Priority: -- → P3
Target Milestone: Future → mozilla0.9.5
Target Milestone: mozilla0.9.5 → mozilla1.0
Bugs targeted at mozilla1.0 without the mozilla1.0 keyword moved to mozilla1.0.1 (you can query for this string to delete spam or retrieve the list of bugs I've moved)
Target Milestone: mozilla1.0 → mozilla1.0.1
Looks like the normal nsIFile::CopyTo method is recursive now (I checked win, unix, mac implementations) does this mean this bug can be closed?
Yes this has been fixed in copyTo.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: