Copying folders and their contents

Jul 11, 2013 at 6:29pm
Hi. I'm pretty new to programming but I have an ok handle on it. I normally do scripting and I used the xcopy command in a batch file to copy a folder from one location to another. I want to copy the same folder using C++. Unfortunately, I got someone who recommended using system() but I don't particularly like using that. I need to be pointed to what command I should be using other than system if at all possible. If system really is the most effective way of doing it then I understand. I also found references to an SHFileOperation function, but I found the Microsoft page for it rather complex for me given I only started doing this a couple weeks ago. Any ideas? (No copy paste solutions please. Then I'll learn less.)
Last edited on Jul 11, 2013 at 6:35pm
Jul 11, 2013 at 6:37pm
closed account (NUj6URfi)
System is.
Jul 11, 2013 at 6:46pm
closed account (Dy7SLyTq)
no its not. what compiler are you using?
Jul 11, 2013 at 6:48pm
Oh right, Code::Blocks so whatever the default is. Actually thats another question. Is Code::Blocks the Compiler or just the interface for a number of compiler's?
Jul 11, 2013 at 6:51pm
Nevermind, its an interface and the compiler is GNU GCC
Jul 11, 2013 at 6:52pm
closed account (Dy7SLyTq)
yes your right. i would look into the boost api or fstream + sys/stat + sys/types + dirent
Jul 11, 2013 at 6:55pm
Yeah, I'm gonna pull the noob card and ask "What!?" I have 0 education in C++. Are these like "classes" I need to call or functions or some such? Which is to say, can I find these things in the reference material?

After an answer to that Ill mark this bad boy solved.
Last edited on Jul 11, 2013 at 6:56pm
Jul 11, 2013 at 6:57pm
closed account (Dy7SLyTq)
boost: www.boost.org its essentially this really huge library that has a solution to a lot of problems

the others are standard c and stl libraries
Jul 11, 2013 at 6:58pm
Cool. Thanks for the help. I just find the system() way of doing things to be less than elegant. I already know enough scripting and that just makes me revert back to it.
Jul 11, 2013 at 6:59pm
closed account (Dy7SLyTq)
system is very evil and should rarely be used
Jul 11, 2013 at 7:01pm
I've been reading it's a problem with security? Or is it just that it gives people the ability to be lazy?
Jul 11, 2013 at 7:02pm
closed account (Dy7SLyTq)
both. if i have a malicous program that i name pause and put it in your system32 you will run it
Jul 11, 2013 at 7:04pm
Ha! That's wonderful. Ok, so I will avoid using any system(). I'm assuming I need to download the library zip file, and then unpack it into some folder within the CodeBlocks directory?

Edit: that's why they make a getting started guide!
Last edited on Jul 11, 2013 at 7:04pm
Jul 11, 2013 at 7:06pm
closed account (Dy7SLyTq)
yep boost is a better solution but also a bigger one
Jul 11, 2013 at 7:10pm
Any recommendations that can help me learn syntax (I'm assuming that is the correct term)? That has been the hardest thing to wrap my head around. Or is it like any other spoken language in that you just have to spend time with it?
Jul 11, 2013 at 7:11pm
closed account (Dy7SLyTq)
well boost is written in c++. its just learning the functions and classes
Jul 11, 2013 at 7:24pm
I got that it's written in C++. My question more pertained to C++. I apologize, I should have been more specific. I'm only into this because there is a lull in the work at my job right now and I wanted to expand what I know. Well, and like every boyhood dream, I one day would like to write my own game but that's a long way off and I'm content to make little .exe's for the moment to help me learn.
Jul 11, 2013 at 7:26pm
closed account (Dy7SLyTq)
oh you just meant in general? right programs that reinvent the wheel and ground in the features of c++. for example you could rewrite the cmath library
or make a container (not an stl standard one though)
Jul 11, 2013 at 7:47pm
THAT sounds like a good idea. I've been asking people for ideas and that seems like a fun one. I'll make a copy of the cmath library. I don't want to screw up and then end up having to find the library again or whatever. I'll treat it like a reg file.

EDIT: Wow, that looks intense. I think I need some more training time. I'm not a C savant. But yeah, as soon as I think I can handle that I'll start doing that stuff. Sounds like and looks like fun actually.
Last edited on Jul 11, 2013 at 7:51pm
Topic archived. No new replies allowed.