[Lazarus] Configuration data in Linux?
bo.berglund at gmail.com
Tue Sep 28 10:42:55 CEST 2010
2010/9/28 Žilvinas Ledas <zilvinas.ledas at dict.lt>:
> On 2010-09-28 09:24, Bo Berglund wrote:
>> So can I get some advice on:
>> - What is the common way to store config data on Linux?
>> Ini files are probably not used since they are Windowsisms,
>> but is there some other easily used way where one can simply
>> store and retrieve individual values without scanning through
>> a text file?
>> - Where is the agreed location for such data?
> In Lazarus you can use:
> function GetAppConfigDirUTF8(Global: Boolean): string;
> function GetAppConfigFileUTF8(Global: Boolean; SubDir: boolean = false):
> to get correct config dir/file name in (various versions of)
So to summarize there *is* a convention on the file location depending
on if the data are user specific or global. The name of the file is
the application name preceded by a period. No extension.
But there is no convention regarding the format of this file apart
from it being in ASCII only.
So I could create an IniFile class to handle the config and let it
have methods for reading/writing private and global config data into a
file which it determines by itself depending on its call. Then I would
be doing the right thing? I could use the format of windows ini files
(which we are accustomed to) and still be OK on Linux...
Methods could be overloaded as:
ReadIniString(section, item, default: string);
ReadIniString(section, item, default: string; global: boolean);
where the first version uses the current user's private area and the
second one uses the global area. Otherwise they are identical.
More information about the Lazarus