Game cannot write to its installation folder


I just recently finished up a game in A5, used the nullsoft installer to create a deployment package, went over to my wife's laptop (running Windows XP Professional), installed ok, ran ok up until the point it need to save data to a file (I'm using the Boost library for serialization):

Code like this:

1std::ofstream output_file("Data/db_joystickconfig.dat", std::ios::binary); 2boost::archive::binary_oarchive oa(output_file); 3oa << joystickMapping; 4output_file.close();

"Data" is a folder off the installation root (ie: c:\Program Files\My Game\).
"joystickMapping" is just a struct defined elsewhere.

Anyone have experience with this? It runs fine if I launch the shortcut as Administrator, so I know it's permission related, just not sure how to "force" it or give it permission to write.


Thomas Fjellstrom

That's modern OSs for you. you can't write to system directories. You need to use the user's or shared user's data directory. in A5, you can use the al_get_standard_path function for that. Otherwise you basically need operating specific apis to get that information.

Matthew Leverton

Sounds like you should be saving to the ALLEGRO_USER_SETTINGS_PATH location.

  1. al_set_org_name()

  2. al_set_app_name()

  3. al_get_standard_path(ALLEGRO_USER_SETTINGS_PATH)

  4. al_make_directory() if does not exist (no guarantee that it does)

  5. Create a path based off of that directory + db_joystickconfig.dat via al_set_path_filename()

Thomas Fjellstrom

And if you want to write actual data (and not config), you use ALLEGRO_USER_DATA_PATH.


Awesome, thanks guys. My first Windows game, not used to all this security stuff. I appreciate your help.


l j

There's a special folder for saved games on windows vista and newer versions of windows, the allegro API doesn't support anything to find this folder though. Might be useful to have a function that returns a special path to the saved games folder if one is available.

Anyway, some games do save to the program files folder directly. It can be done by requesting admin privileges.


taron said:

Anyway, some games do save to the program files folder directly. It can be done by requesting admin privileges.

Taron, how does one request admin privileges within the game?

Thomas Fjellstrom

You don't want to. The user will get a big scary UAC popup.

Thread #613656. Printed from