Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: INI files on MACOS?


This question is answered.


Permlink Replies: 10 - Last Post: Dec 1, 2014 8:59 AM Last Post By: Grant Beattie
Michael Leahy

Posts: 239
Registered: 5/9/07
INI files on MACOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 24, 2014 11:44 AM
Delphi XE7 Firemonkey MACOS

I want to store my app's settings. Is an INI file the way to go on MACOS? If so, where should the INI file be stored?
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: INI files on MACOS?
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 24, 2014 12:40 PM   in response to: Michael Leahy in response to: Michael Leahy
Am 24.11.2014 20:44, schrieb Michael Leahy:
Delphi XE7 Firemonkey MACOS

I want to store my app's settings. Is an INI file the way to go on MACOS? If so, where should the INI file be stored?

Hello,

look at the classes privoded by the IOUtils unit.
If I'm not mistaken TPath or so contains some methods for getting system
paths of various kinds. The one for such user settings files should be
among those.

Greetings

Markus
Michael Leahy

Posts: 239
Registered: 5/9/07
Re: INI files on MACOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 26, 2014 10:17 AM   in response to: Markus Humm in response to: Markus Humm
Markus Humm wrote:
Am 24.11.2014 20:44, schrieb Michael Leahy:
Delphi XE7 Firemonkey MACOS

I want to store my app's settings. Is an INI file the way to go on MACOS? If so, where should the INI file be stored?

Hello,

look at the classes privoded by the IOUtils unit.
If I'm not mistaken TPath or so contains some methods for getting system
paths of various kinds. The one for such user settings files should be
among those.

Greetings

Markus

Thanks, Markus.

I had a look IOUtils. There are all kinds of functions like...

class function GetSharedMoviesPath: string; static;
class function GetAlarmsPath: string; static;


...but I could not find a function for returning a path suitable for app data other than the documents path. I'm assuming there is a place to write INI files that will not alarm the OS's security sensibilities and won't be in a place that users can conveniently delete them.

Where are those paths for MSWINDOWS and MACOS?
Brian Hamilton ...

Posts: 556
Registered: 10/14/04
Re: INI files on MACOS?
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 26, 2014 10:34 AM   in response to: Michael Leahy in response to: Michael Leahy
use
gethomepath
and then add the Documents folder after that and then maybe create your own apps folder there
thats what I do
also note its a tmeminfile
(i.e you need to use the savetofile force to actually update to disk if its not being freed)
Michael Leahy

Posts: 239
Registered: 5/9/07
Re: INI files on MACOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 26, 2014 10:58 AM   in response to: Brian Hamilton ... in response to: Brian Hamilton ...
Brian Hamilton wrote:
use
gethomepath
and then add the Documents folder after that and then maybe create your own apps folder there
thats what I do
also note its a tmeminfile
(i.e you need to use the savetofile force to actually update to disk if its not being freed)

        theFileName := TPath.GetHomePath + TPath.DirectorySeparatorChar + 'opendocs.INI';
 
        theINIFile := TIniFile.Create(theFileName);


My Windows machine returns...

C:\Users\Mike\AppData\Roaming\opendocs.INI

The "Roaming" scares me. Is this folder persistent?

Also, is there a reason to use a TMemINIFile and then force it to write rather than just use a regular TINIFile?

Edited by: Michael Leahy on Nov 26, 2014 10:58 AM
Brian Hamilton ...

Posts: 556
Registered: 10/14/04
Re: INI files on MACOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 26, 2014 11:38 AM   in response to: Michael Leahy in response to: Michael Leahy
the thread title is refering to OSX though
(FMX uses tmeminifile)
Linden ROTH

Posts: 467
Registered: 11/3/11
Re: INI files on MACOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 26, 2014 12:32 PM   in response to: Michael Leahy in response to: Michael Leahy
Michael Leahy wrote:
Brian Hamilton wrote:
use
gethomepath
and then add the Documents folder after that and then maybe create your own apps folder there
thats what I do
also note its a tmeminfile
(i.e you need to use the savetofile force to actually update to disk if its not being freed)

        theFileName := TPath.GetHomePath + TPath.DirectorySeparatorChar + 'opendocs.INI';
 
        theINIFile := TIniFile.Create(theFileName);


My Windows machine returns...

C:\Users\Mike\AppData\Roaming\opendocs.INI

The "Roaming" scares me. Is this folder persistent?

Also, is there a reason to use a TMemINIFile and then force it to write rather than just use a regular TINIFile?

Edited by: Michael Leahy on Nov 26, 2014 10:58 AM

Seems a good enough location for EMB, MS, Mozilla, Logitech, VMware, Adobe, ...........................................

http://windows.microsoft.com/en-au/windows-8/what-appdata-folder

Roaming. This folder (%appdata%) contains data that can move with your user profile from PC to PC—like when you’re on a domain—because this data has the ability to sync with a server. For example, if you sign in to a different PC on a domain, your web browser favorites or bookmarks will be available.
--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"
Grant Beattie

Posts: 77
Registered: 11/29/01
Re: INI files on MACOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 1, 2014 8:58 AM   in response to: Linden ROTH in response to: Linden ROTH
I place an INI file in GetDocumentsPath(). This works in the sandbox as well. I create an application subdirectory in there first of course.

Edited by: Grant Beattie on Dec 1, 2014 8:58 AM
Linden ROTH

Posts: 467
Registered: 11/3/11
Re: INI files on MACOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 26, 2014 10:35 AM   in response to: Michael Leahy in response to: Michael Leahy
Michael Leahy wrote:
Markus Humm wrote:
Am 24.11.2014 20:44, schrieb Michael Leahy:
Delphi XE7 Firemonkey MACOS

I want to store my app's settings. Is an INI file the way to go on MACOS? If so, where should the INI file be stored?

Hello,

look at the classes privoded by the IOUtils unit.
If I'm not mistaken TPath or so contains some methods for getting system
paths of various kinds. The one for such user settings files should be
among those.

Greetings

Markus

Thanks, Markus.

I had a look IOUtils. There are all kinds of functions like...

class function GetSharedMoviesPath: string; static;
class function GetAlarmsPath: string; static;


...but I could not find a function for returning a path suitable for app data other than the documents path. I'm assuming there is a place to write INI files that will not alarm the OS's security sensibilities and won't be in a place that users can conveniently delete them.

Where are those paths for MSWINDOWS and MACOS?

top of my head while 1/2 asleep

put a directory into Home path with a DOT as first char ... is now invisible to normal viewing ... put your data in there

uses
   System.SysUtils
 
settingfile := GetHomePath + PathDelim + '.MYAPPSTUFF' + PathDelim + 'SETTINGS.INI'


--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"
Michael Leahy

Posts: 239
Registered: 5/9/07
Re: INI files on MACOS?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 26, 2014 11:02 AM   in response to: Linden ROTH in response to: Linden ROTH
Linden ROTH wrote:
Michael Leahy wrote:
Markus Humm wrote:
Am 24.11.2014 20:44, schrieb Michael Leahy:
Delphi XE7 Firemonkey MACOS

I want to store my app's settings. Is an INI file the way to go on MACOS? If so, where should the INI file be stored?

Hello,

look at the classes privoded by the IOUtils unit.
If I'm not mistaken TPath or so contains some methods for getting system
paths of various kinds. The one for such user settings files should be
among those.

Greetings

Markus

Thanks, Markus.

I had a look IOUtils. There are all kinds of functions like...

class function GetSharedMoviesPath: string; static;
class function GetAlarmsPath: string; static;


...but I could not find a function for returning a path suitable for app data other than the documents path. I'm assuming there is a place to write INI files that will not alarm the OS's security sensibilities and won't be in a place that users can conveniently delete them.

Where are those paths for MSWINDOWS and MACOS?

top of my head while 1/2 asleep

put a directory into Home path with a DOT as first char ... is now invisible to normal viewing ... put your data in there

uses
   System.SysUtils
 
settingfile := GetHomePath + PathDelim + '.MYAPPSTUFF' + PathDelim + 'SETTINGS.INI'


--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"

Thanks, Linden.

This trick of starting a folder name with a DOT...

Does this work on both MACOS and MSWINDOWS?
Linden ROTH

Posts: 467
Registered: 11/3/11
Re: INI files on MACOS?
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 26, 2014 12:27 PM   in response to: Michael Leahy in response to: Michael Leahy
Michael Leahy wrote:

Thanks, Linden.

This trick of starting a folder name with a DOT...

Does this work on both MACOS and MSWINDOWS?

the hidden by a dot is a Unix thing (and OSX is Unix)

If you need to in windows you can set the hidden attribute

from the source

{ GetHomePath returns the path to the current user's home directory on MacOSX and
  Linux. On Windows it returns the path to the current user's AppData folder. GetHomePath
  is useful when an application requires storing user-specific files. }


--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02