how can you have your program copying files/make folders?

Started by
11 comments, last by SiCrane 18 years, 9 months ago
i'm trying to write a program to install my game. of course to do this, i need to be able to copy my game files in to the correct dic. how do i do this, i'm guessing there is some function that can do it? thanks.
Charles Reed, CEO of CJWR Software LLC
Advertisement
well, you could have a list of the files you need to copy, get a dir input from the user and then open the files, one at a time, read the data and then write it to a new file thats opened with the same name in the specified dir.
yes, but what are the commands to do such a thing. i understand the goal, just not the commands lol.
Charles Reed, CEO of CJWR Software LLC
Quote:Original post by CJWR
yes, but what are the commands to do such a thing. i understand the goal, just not the commands lol.


There are no standard C nor C++ functions to do so. Filesystem is a service that is provided by your operating system. If you're using Windows, you'll be wanting to use something like the obviously-named CopyFile and CreateDirectory functions.

Enjoy.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
CreateFile to make a directory
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/createfile.asp

CopyFile to...well take a guess :D
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/copyfile.asp
if you want it cross platform I guess you could use
fopen();
fread();
fwrite();

As for directories thats platform specific i beleive- i may be wrong.
Why don't you just use one of the many freely available installers?
Quote:Original post by bytecoder
Why don't you just use one of the many freely available installers?


too easy [smile]

ok, heres some of the steps I would go through if I was making this cross platform:

-Get the list of files to copy
-get a user input on the directory
-open the file (fopen()), get the file length, create a char buffer the size of the file (char *buf=new char[nFileSize];) and then copy the data from the file into the buffer
-close that file (fclose()) and open a new file in the directory with that filename (fopen())
-write all the data from the buffer into the new file
-repeat process for every file
Yeah. Check out the free installers at:

www.dev4pc.com

They are pretty easy to use and don't require annoying scripts.


Mr. Creamy.
Quote:Original post by Anonymous Poster
Yeah. Check out the free installers at:

www.dev4pc.com

They are pretty easy to use and don't require annoying scripts.


Mr. Creamy.


ah nice, i didn't know there were free installers!

thanks, i'll look into using one of those then.
Charles Reed, CEO of CJWR Software LLC

This topic is closed to new replies.

Advertisement