www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - copying a directory

reply jicman <cabrera_ _wrc.xerox.com> writes:
Greetings.

Is there a command for std.file to copy a directory?  I know that I can use
mkdir and then copy all the files in there, but is there any place a copyDir
command?

thanks.
May 17 2007
next sibling parent Gregor Kopp <gregor.kopp chello.at> writes:
I think, if you want to do a deep copy (recursive), it's just good to 
use existing programs like xcopy on windows, or a linux pendant.
You can call these programs from your d-program.
Only my thoughts


jicman schrieb:
 Greetings.
 
 Is there a command for std.file to copy a directory?  I know that I can use
 mkdir and then copy all the files in there, but is there any place a copyDir
 command?
 
 thanks.
May 17 2007
prev sibling next sibling parent reply Regan Heath <regan netmail.co.nz> writes:
jicman Wrote:
 
 Greetings.
 
 Is there a command for std.file to copy a directory?  I know that I can use
 mkdir and then copy all the files in there, but is there any place a copyDir
 command?
 
 thanks.
Not that I recall but I've been away for a while so there might be. I think ideally you want a function that uses the API to list files and for each file or directory it calls a callback (function/delegate) to perform the correct operation. This general idea can be re-used for (optionally recursive) copy, delete, and any other change you might want to apply to a group of files and/or directories. I wrote something just like this for my work on installers in the past. You can also abstract out the source of the file listing, getting it from an FTP server, or database, or ... you end up with a library just like Matthew Wilson's one (I forget the name, sorry). Regan Heath
May 18 2007
parent reply Frank Benoit <keinfarbton googlemail.com> writes:
sounds like this:
http://www.dsource.org/projects/tango/wiki/ChapterIO#FilePath

See the "toList" function.
May 18 2007
parent reply jicman <cabrera_ _wrc.xerox.com> writes:
== Quote from Frank Benoit's article
 sounds like this:
 http://www.dsource.org/projects/tango/wiki/ChapterIO#FilePath
 See the "toList" function.
Yeah, that is beautiful. The problem is that all of my code has been Phobos'ed. And I have had bad history with new startup libraries. No disrespect to anyone here nor in the tango team. But, most folks start projects with great enthusiasm, and then, BOOOOM, they either stop, drastically change things or simply disappear. And, by the way, I understand. Time is not what it used to be, so priorities change. :-) Folks around here think that I am crazy, because I started to believe the speed of light is starting to slow down. This means that energy is not what is used to be, so E=MC^2 does not have the pep that it once had. :-) Anyway, I know Walter will keep Phobos going, so I have faith in Phobos. Thanks for the suggestion... josé
May 21 2007
parent reply John Reimer <terminal.node gmail.com> writes:
On Tue, 22 May 2007 00:24:10 +0000, jicman wrote:

 == Quote from Frank Benoit's article
 sounds like this:
 http://www.dsource.org/projects/tango/wiki/ChapterIO#FilePath
 See the "toList" function.
Yeah, that is beautiful. The problem is that all of my code has been Phobos'ed. And I have had bad history with new startup libraries. No disrespect to anyone here nor in the tango team. But, most folks start projects with great enthusiasm, and then, BOOOOM, they either stop, drastically change things or simply disappear. And, by the way, I understand. Time is not what it used to be, so priorities change. :-) Folks around here think that I am crazy, because I started to believe the speed of light is starting to slow down. This means that energy is not what is used to be, so E=MC^2 does not have the pep that it once had. :-) Anyway, I know Walter will keep Phobos going, so I have faith in Phobos. Thanks for the suggestion... josé
The fact that Tango has been in development for well over a year (with major parts well over three years) tells me that it has the momentum to keep going. I have complete faith in Tango and it's crew. -JJR
May 21 2007
parent jicman <cabrera_ _wrc.xerox.com> writes:
== Quote from John Reimer's reply

 The fact that Tango has been in development for well over a year
 (with major parts well over three years) tells me that it has the
 momentum to keep going.  I have complete faith in Tango and it's crew.
I agree. I also have faith. I can also see that it is also becoming a more complete than Phobos. Like I said, all of my programs are Phobos based. So, it will take me a while to switch. :-) jic
May 22 2007
prev sibling next sibling parent reply Manfred Nowak <svv1999 hotmail.com> writes:
jicman wrote

 is there any place a copyDir command?
Wasn't it in std.recls? -manfred
May 18 2007
parent jicman <cabrera_ _wrc.xerox.com> writes:
== Quote from Manfred Nowak's article
 jicman wrote
 is there any place a copyDir command?
Wasn't it in std.recls?
It coulda been... :-)
May 21 2007
prev sibling parent reply Regan Heath <regan netmail.co.nz> writes:
jicman Wrote:
 
 Greetings.
 
 Is there a command for std.file to copy a directory?  I know that I can use
 mkdir and then copy all the files in there, but is there any place a copyDir
 command?
jicman - In case you're using phobos (and not tango) here is a copyDir using phobos std.file functions. Walter - please feel free to include these functions in std.file in this form or modified to suit the phobos style. Is there an official place to submit new code for phobos? This code is public domain. I cannot guarantee this code has been fully tested.
May 18 2007
next sibling parent jicman <cabrera_ _wrc.xerox.com> writes:
== Quote from Regan Heath's article
 This is a multi-part message in MIME format
 ------------15658639521179527726
 Content-Type: text/plain
 jicman Wrote:
 Greetings.

 Is there a command for std.file to copy a directory?  I know that I can use
 mkdir and then copy all the files in there, but is there any place a copyDir
 command?
jicman - In case you're using phobos (and not tango) here is a copyDir using
phobos std.file functions.
 Walter - please feel free to include these functions in std.file in this form
or
modified to suit the phobos style. Is there an official place to submit new code for phobos?
 This code is public domain.  I cannot guarantee this code has been fully
tested.
Thank Reagan.
May 21 2007
prev sibling parent reply jicman <cabrera wrc.xerox.com> writes:
Reagan,

would you mind sending it to me?  Somehow I can not download it.  Xerox is so
stupid carefully with downloading things that it stops us from doing real work.

Thanks.

josé
May 21 2007
next sibling parent jicman <cabrera_ _wrc.xerox.com> writes:
== Quote from jicman's article
 Reagan,
 would you mind sending it to me?  Somehow I can not download it.  Xerox is so
 stupid carefully with downloading things that it stops us from doing real work.
There goes my job... :-) I tried to send this to Regan and somehow go to the newsgroup... Sorry about that folks. Somehow, I forgot to click on the "Do not post". That is why we have "digitalmars.D.learn".
May 21 2007
prev sibling parent Regan Heath <regan netmail.co.nz> writes:
jicman Wrote:
 Reagan,
 
 would you mind sending it to me?  Somehow I can not download it.  Xerox is so
 stupid carefully with downloading things that it stops us from doing real work.
No problem, expect it soon. Regan
May 22 2007