   Cross-Platform Filesystem Writing
  I'm wondering what concerns I should have in performing cross-platform filesystem writing?  By cross-platform I mean Windows, OS X, and Linux (including their different versions in use -- such as XP and Vista, etc.).  What I'm unsure of is if there are security/permission considerations to be aware of.  I don't want scary messages to popup for Vista users saying my program might be harming something, nor do I want the writes to fail because I don't have Linux write permission for the directory, etc.  What do I need to do to support each platform (and where do I have to store the writeable files for each)?Also, what are appropriate APIs to do so (will Boost:filesystem be adequate)?   
Quote:Original post by Gamer GamesterAlso, what are appropriate APIs to do so (will Boost:filesystem be adequate)?It's not enough. Each platform has various conventions on which data is stored where and how. Some platforms enforce it, others specify it via configuration.Quote:what concerns I should have in performing cross-platform filesystem writing?An answer to such generic question is: use Java.Otherwise it helps to specify exactly what will get written and why.   ;  I would have configuration variables that indicate where all the relevant directories are, and then ensuring that the permissions are correct is the responsibility of the installer, which will have to be platform specific.   ;Quote:Originally posted by AntheusOtherwise it helps to specify exactly what will get written and why.I have a few different things I'd like to write (if possible, otherwise I guess I don't get what I 'like' [wink]):1) Savegame DataThis is so common there must be a way (though I don't know if there's a cross-platform API).  Any good resources to get up to speed?2) Python ScriptsIs it possible to write these to a file (With the intention of later feeding them into the interpreter?)  The logic behind it is something like: game checks internet, game downloads some new content (in form of Python script), game runs content.  By downloading and keeping script on computer, information doesn't have to be re-transferred over Internet each time.3) Media (images, sounds, etc.)To be used by above scripts.4) Python Modules (written & compiled in C/C++)To be used by above scripts.Can I do any (or hopefully all) of these?  Advice and pointers to references are much appreciated.   ;  Short and simplified overview follows. Never hardcode the path prefixes, as they may change depending on the language version of the OS. Always use OS API calls to get the paths given the appropriate location UUIDs. Keep in mind that the OS can return Unicode paths.* Executable code and non-mutable data files (read-only after install):Windows: usually some folder under Program Files. Let the user decide on installation. Needs admin privileges to install, but not to read/execute. You can't write anything in there once installed. OSX: Create an application bundle, and let the user install (drag) it into /Applications (or wherever he wants).* Per-user generated files that can't directly be accessed by the user (config files, savegames, logs, etc):Windows: A subfolder under CSIDL_LOCAL_APPDATA would be appropriate. Read/writable for the respective user.OSX: A subfolder under kApplicationSupportFolderType (usually ~/Library/Application Support, but that may change with locale). Read/writable for the respective user.* Per-user browsable data (editor project files, documents, libraries, etc):Windows: A subfolder under CSIDL_PERSONAL. Obviously read/write access for the respective user.OSX: A subfolder under kDocumentsFolderType (usually ~/Documents). Also read/write access for current user.   ;  Extending Yann's categories to linux...* Executable code and non-mutable data files (read-only after install):Linux: Somewhere in the $PATH variable, generally one of /usr/bin, /usr/local/bin or ~/bin. Varies by distro, so best to let the user choose.* Per-user generated files that can't directly be accessed by the user (config files, savegames, logs, etc):Linux: A subfolder of the user's home directory, prefixed with a period/fullstop. For example: ~/.mygame* Per-user browsable data (editor project files, documents, libraries, etc):Linux: No set convention, recommend a subfolder under the user's documents directory, eg. ~/Documents/mygame   ;  I think PhysicsFS helps with cross platform file I/O stuff:quote from the websiteQuote:PhysicsFS is a library to provide abstract access to various archives. It is intended for use in video games, and the design was somewhat inspired by Quake 3's file subsystem......Finally, PhysicsFS gives you platform-abstracted means to determine if CD-ROMs are available, the user's home directory, where in the real filesystem your program is running, etc.http://icculus.org/physfs/   ;  Thank you for the detailed responses!   