Sign in to follow this  
CJWR

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

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest 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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
If you're really interested in writing your own though, you might wanna look into POSIX. I know MS was forced to have it until NT by the US government, but I'm not sure if it's still implemented, or if you have to download and install a package.

Share this post


Link to post
Share on other sites
If you don't plan to use an existing installer or one of the many happy scripting languages that make this easy, and you plan in doing this in C++ (I didn't see a programming language listed, but I've been going blind lately), I would use boost::filesystem. It has nice happy functions for creating directories and copying files.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this