Environment variable for application storage under OSX ?
FreeSlave via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 17 00:54:41 PDT 2015
On Friday, 17 July 2015 at 07:33:43 UTC, Anonymous wrote:
> On Friday, 17 July 2015 at 07:14:24 UTC, FreeSlave wrote:
>> On Thursday, 16 July 2015 at 21:12:05 UTC, anonymous wrote:
>>> I have the following code, working under Win and Linux:
>>>
>>> ---
>>> import std.process: environment;
>>>
>>> immutable string p;
>>>
>>> static this() {
>>> version(Win32) p = environment.get("APPDATA");
>>> version(linux) p = "/home/" ~ environment.get("USER");
>>> version(OSX) p = "?";
>>> }
>>> ---
>>>
>>> what would be the OSX equivalent (to get the path where the
>>> applications data are commonmly stored)?
>>
>> Hello. You may take a look at this library
>> https://github.com/MyLittleRobo/standardpaths
>> OSX version uses Carbon though. You may want to use Cocoa API
>> (which is newer), but it's Objective-C.
>> Also you may consider standard path for data storage without
>> using any api or spec. It's usually $HOME/Library/Application
>> Support/ on OSX.
>
> So for a software named 'SuperDownloader2015' it would be
>
> $HOME/Library/Application Support/SuperDownloader2015
>
> right ?
>
> so it's not user-specific and it's writable for the current
> user ?
> sorry but it looks a bit strange, anyone can confirm ?
It is user specific obviously since it's in user home.
Can you elaborate on what do you want exactly?
From Windows and Linux examples you provided I assumed you need
user-specific paths (APPDATA is defined per user on Windows).
System-wide application data path is different.
More information about the Digitalmars-d-learn
mailing list