Sign in to follow this  
Carradine

How to allow file create/read/write/modify access in Program Files for a patcher

Recommended Posts

I have a auto-patcher for my game which downloads and updates files just like most patchers for games.  I create a dummy file called "temp.xxx", insert the file data into the file as it gets transferred from the server, then once the data is all received, I call rename() to rename the file to the actual name, and the function also moves it to the correct destination directory.

 

However, since many users have access restriction to creating/deleting/renaming files that need confirmations, file creation fails.

 

The patcher works fine if I install the game into the Users/Appdata directory where most users have full rights, however some people get the same error there as well.

 

To create a file I simply use:

 

std::ofstream recvFile;

recvFile.open( VGlobal::CURRWORKDIR + VGlobal::CurrTempFileDir + "Temp.txt", std::ios_base::out | std::ios_base::binary );

 

 So my question is, how can I get around this access restriction?  Can I change the folder settings in code?  Should I use something other than recvFile.open(...), and rename() to change the file name and move the file to another location?

 

Thanks for any help.

Share this post


Link to post
Share on other sites
You're basically asking how to circumvent a very important security feature... there are ways, but you don't want to do them :-)

The cop-out general answer is to not install to Program Files if you need to auto-update your binaries. Alternately, don't install anything you need to update to a subdirectory of Program Files.

Share this post


Link to post
Share on other sites

Wow, I actually wasn't expecting that answer but thanks.  Like I said, I already install the files into the Users/AppData directory and that works for most people.  But even some of them seem to have problems installing there due to access restrictions.  Some of them can simply change their restrictions, but of course I need my game to work "right out of the box".  My game was submitted the Independent Games Festival, and even though all my testers can run the game, the IGF Judge cannot because of this.

Share this post


Link to post
Share on other sites

You can install your core app to "program files" folder, which will not be updated.

Then your core app installs updatable app/resources to a writable folder.

Your "core app" only does two jobs:

1, Check auto update

2, Execute your main app from the writable folder.

 

This is how we did auto update in mobile games. Hope it helps.

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