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

Started by
4 comments, last by wqking 10 years, 6 months ago

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.

--------------------------Vantage: Greenlit on Steam / Independent Games Festival Submission http://www.crystaldragon.com

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

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

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.

--------------------------Vantage: Greenlit on Steam / Independent Games Festival Submission http://www.crystaldragon.com

If you're going to have a patcher, then your patcher should be setup to request privilage escalation when launched or by running a seperate setup instance that requests privilage escalation.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

I will definitely work on this, thanks for the info!

--------------------------Vantage: Greenlit on Steam / Independent Games Festival Submission http://www.crystaldragon.com

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.

https://www.kbasm.com -- My personal website

https://github.com/wqking/eventpp  eventpp -- C++ library for event dispatcher and callback list

https://github.com/cpgf/cpgf  cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.

This topic is closed to new replies.

Advertisement