C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 14th, 2004, 12:49 PM
Adriaan Adriaan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 Adriaan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Copying complete Folders in C++!

Hey,

Pleas can anyone help me with this problem.
I know the regular copy function:

system("copy file file");

but how to copy a complete folder (with this function it wont work)

thx a lot,

Adriaan

Reply With Quote
  #2  
Old September 23rd, 2005, 01:32 AM
ezmac ezmac is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 1 ezmac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 9 sec
Reputation Power: 0
if youre looking to do a system call for it, use the command xcopy. there is a switch to make it not ask if it is a folder or a file. xcopy /? for help. windows only, though
Comments on this post
MichaelSoft agrees: also available for DOS ;-)

Reply With Quote
  #3  
Old October 5th, 2005, 03:11 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 996 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2Folding Points: 808001 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 14 h 5 m 52 sec
Reputation Power: 5
Send a message via ICQ to Itsacon
'xcopy /e' copies entire directories, recursively.

On linux, use 'cp -R'

PS: sorry for necromancing...
Comments on this post
Icon agrees: straighten your code, pinch your compilers nose and blow into main() hole?
__________________
This is my code. Is it not nifty?

"The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools."
---Douglas Adams


Join the Itsacon fanclub!    
Zero Tolerance: Spammers banned so far: 275

Reply With Quote
  #4  
Old October 5th, 2005, 04:11 AM
Icon's Avatar
Icon Icon is offline
Command Line Warrior
Click here for more information.
 
Join Date: Sep 2005
Posts: 704 Icon User rank is Private First Class (20 - 50 Reputation Level)Icon User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 3 Days 6 m 49 sec
Reputation Power: 4
System() (which is not the definition of a system call!) only returns the return value of that shell command. If you want to have more control you could write your own copier (just with opening, reading and writing files).

For windows there is a copy function CopyFile (which is of course a system call..) you can use, example:
http://www.geocities.com/rodolfofrino/CopySubdirectory.html

To 'browse' a directory you can use opendir/readdir for linux and findNextfile for windows (this is also in the example). An alternative for linux is using glob().

With these functions you can have more control and do better error checking and feedback. But it is a lot more work

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Copying complete Folders in C++!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT