The client software for my SMS suite is cross platform. The main program is written is VB.NET which is obviously not cross platform, so the client software is being developed in REALbasic, which allows me to develop on my platform of choice (OSX) but compile the finished application for OSX, Windows and Linux. One of the issues I faced is where to put the Preferences file. Originally I stored it in the program directory, then I changed my mind and wrote some code to test for the platform and put the file in a more appropriate place, according to current platform.
Today I discovered ‘PreferencesFolder’, a FolderItem object that holds the location of the ideal place to store the preferences, according to platform. REALBasic defines the appropriate place as:
OSX: /Users/{username}/Library/Preferences
Windows: C:\Documents and Settings\{username}\Application Data
Linux: /home/{username}
Thats good enough for me :-)
I have the following code now that sets a property with the path and filename for the Preferences files:
pScreenSettingsFileName = PreferencesFolder.AbsolutePath + pProgramName + "ScreenSettings.ini"
pGeneralSettingsFileName = PreferencesFolder.AbsolutePath + pProgramName + "GeneralSettings.ini"
and when loading or saving the Preferences:
'Open File Stream
f = GetFolderItem(mProgramInfo.pScreenSettingsFileName)
I’m quite pleased because I am storing the file where it should be stored and haven’t had to resort to any switching code according to platform :-)
"All I can say about life is, Oh God, enjoy it!" - Bob Newhart
Friday, 6 June 2008
SMSRelay Suite: Cross Platform Preferences
Labels:
stevechol ArtenScience,
stevechol SMSRelay
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment