PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, September 10, 2022

[FIXED] Where should cross-platform apps keep their data?

 September 10, 2022     cross-platform     No comments   

Issue

I'm building an application that is targeting Windows, Mac and Linux soon. I was wondering where should I keep application data such as settings, etc.

Application's installation folder is the easiest choice, but I think that might be a problem with new Vista security model. Besides, users might want different settings.

Is it C:\Documents and Settings\username\MyApp good for both Vista and XP? Is it /home/username/.MyApp good for Linux and Macs?

Any ideas and/or links to best practices much appreciated.

Thanks!

Juan


Solution

Each platform has its own API for finding the user's home folder, or documents folder, or preferences folder.

  • Windows: SHGetFolderPath() or SHGetKnownFolderPath()
  • Mac OS X and iPhone OS: NSSearchPathForDirectoriesInDomains()
  • Unix: $HOME environment variable

Don't hardcode specific paths or just tack a prefix and suffix on the user's name. Also, try to follow whatever conventions there are for the platform for naming the files.



Answered By - Kristopher Johnson
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing