gravit icon indicating copy to clipboard operation
gravit copied to clipboard

Windows: do not write into program directory

Open FrMo opened this issue 12 years ago • 1 comments

For security reasons, a windows program should not create files into the installation path (C:\program files\gravit\save etc.) similar to linux and MacOS, gravit should use some kind of "home" directory for saving simulations, screenshots, and the stdout.txt / stderr.txt files.

A location in the users profile path should be used, for example C:\Users<Username>\Documents\gravit.

Issues:

  • The "documents and settings" folder can be moved: http://www.w7forums.com/change-location-my-documents-folder-t338.html
  • The path name is different between XP and vista/win7 (http://en.wikipedia.org/wiki/My_Documents)
  • on XP, the path name depends on the language of windows

possible solutions:

  • SCREENSHOT_PATH and SAVE_PATH can be changed in gravit.h what about the location of stdout.txt and stderr.txt ???

  • getenv("USERPROFILE") ==> "C:\Users\Frank"

  • http://en.wikipedia.org/wiki/My_Documents :

    An application can convert environment strings in a user-supplied path (e.g. "%USERPROFILE%\My Documents") to an actual path by (for example) calling the function ExpandEnvironmentStrings.

FrMo avatar Jan 03 '12 18:01 FrMo

Good idea.

With stdout.txt, I believe they're automatically made by SDL in replace of a console.

Looks like you can disable the generation all together if it's not needed: http://sdl.beuc.net/sdl.wiki/FAQ_Console

Another option might be to modify the working directory to the Gravit "Documents" path before initialising SDL so the txt's are written there instead.

gak avatar Jan 04 '12 02:01 gak