Jump to content
  • Advertisement
Sign in to follow this  
CJWR

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

This topic is 4763 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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.

Share this post


Link to post
Share on other sites
yes, but what are the commands to do such a thing. i understand the goal, just not the commands lol.

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
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!