Copying a Directory

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Copying a Directory

Post by Tyler » Sun Apr 10, 2005 3:50 pm

What is the best approach for copying a directory from one location to another? I don't believe wxCopyFile handles directories, and was wondering ifanyone knows a better way other than doing it recursively?

vdell
Moderator
Moderator
Posts: 536
Joined: Fri Jan 07, 2005 3:44 pm
Location: Finland
Contact:

Re: Copying a Directory

Post by vdell » Sun Apr 10, 2005 8:18 pm

On windows, you could use the xcopy command (with the correct switches) via wxExecute().
Visual C++ 9.0 / Windows XP Pro SP3 / wxWidgets 2.9.0 (SVN) | Colligere

Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Post by Tyler » Sun Apr 10, 2005 8:54 pm

yea, I was looking for a wx way to maintain portability

User avatar
Ryan Norton
Moderator
Moderator
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Post by Ryan Norton » Sun Apr 10, 2005 9:10 pm

Tyler wrote:yea, I was looking for a wx way to maintain portability
Then only way I know of is to use wxDir to traverse and then use wxMkDir wxCopyFile as you go...
[Mostly retired moderator, still check in to clean up some stuff]

Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Post by Tyler » Mon Apr 11, 2005 1:08 am

Ryan Norton wrote: Then only way I know of is to use wxDir to traverse and then use wxMkDir wxCopyFile as you go...
Yea, that's what I was afraid. I just wanted to double check to see if anyone had any better ideas. Oh well, another function to add to my utilities library. :D

Thanks!

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Mon Apr 11, 2005 6:54 am

Better yet, make it into a ::wxCopyDir function and contribute ;-)

If you are planning of doing that, I would suggest using wxLogError to list all the files or dirs that could not be copied (e.g. files that could not be opened etc).

Regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Post by Tyler » Mon Apr 11, 2005 12:24 pm

Jorg wrote:If you are planning of doing that, I would suggest using wxLogError to list all the files or dirs that could not be copied (e.g. files that could not be opened etc).
Good thinking Jorgen. Maybe I'll just contribute my whole library.. some of the wrapper functions I've written around the wx functionality have really expedited a lot of my programming.

Thanks,

-Tyler

Post Reply