Thread overview | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 18, 2007 copying a directory | ||||
---|---|---|---|---|
| ||||
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 18, 2007 Re: copying a directory | ||||
---|---|---|---|---|
| ||||
Posted in reply to jicman | 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 18, 2007 Re: copying a directory | ||||
---|---|---|---|---|
| ||||
Posted in reply to jicman | 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 Re: copying a directory | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | sounds like this: http://www.dsource.org/projects/tango/wiki/ChapterIO#FilePath See the "toList" function. |
May 18, 2007 Re: copying a directory | ||||
---|---|---|---|---|
| ||||
Posted in reply to jicman | jicman wrote
> is there any place a copyDir command?
Wasn't it in std.recls?
-manfred
|
May 18, 2007 Re: copying a directory | ||||
---|---|---|---|---|
| ||||
Posted in reply to jicman Attachments: | 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 21, 2007 Re: copying a directory | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | == 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 Re: copying a directory | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | 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 22, 2007 Re: copying a directory | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | == 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 22, 2007 Re: copying a directory | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit | == 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é
|
Copyright © 1999-2021 by the D Language Foundation