digitalmars.D.learn - Environment variable for application storage under OSX ?
- anonymous (12/12) Jul 16 2015 I have the following code, working under Win and Linux:
- byron (2/14) Jul 16 2015 Maybe checkout http://code.dlang.org/packages/standardpaths
- Maeriden (5/17) Jul 16 2015 I'd like to point out that the xdg specification specifies
- FreeSlave (8/20) Jul 17 2015 Hello. You may take a look at this library
- Anonymous (6/30) Jul 17 2015 So for a software named 'SuperDownloader2015' it would be
- FreeSlave (6/38) Jul 17 2015 It is user specific obviously since it's in user home.
- anonymous (14/56) Jul 17 2015 Ok so my sample can be rewritten
- Jacob Carlborg (7/19) Jul 17 2015 Ideally you should hard code the values like this. BTW, why don't you
- Jacob Carlborg (6/11) Jul 17 2015 Yes, that's correct. Some applications skip the "Application Support"
- Jacob Carlborg (4/8) Jul 17 2015 DMD master now has some initial support for Objective-C.
- Jacob Carlborg (15/27) Jul 17 2015 They are usually defined as constants in Objective-C. You can read more
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)?
Jul 16 2015
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)?Maybe checkout http://code.dlang.org/packages/standardpaths
Jul 16 2015
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)?I'd like to point out that the xdg specification specifies subdirectories of the home directory to store application data on linux. I hate when applications litter my home with configuration folders
Jul 16 2015
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.
Jul 17 2015
On Friday, 17 July 2015 at 07:14:24 UTC, FreeSlave wrote:On Thursday, 16 July 2015 at 21:12:05 UTC, anonymous wrote: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 ?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.
Jul 17 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: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.On Thursday, 16 July 2015 at 21:12:05 UTC, anonymous wrote: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 ?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.
Jul 17 2015
On Friday, 17 July 2015 at 07:54:43 UTC, FreeSlave wrote:On Friday, 17 July 2015 at 07:33:43 UTC, Anonymous wrote:Ok so my sample can be rewritten ---- static this() { version(Win32) p = environment.get("APPDATA"); version(linux) p = "/home/" ~ environment.get("USER"); version(OSX) p = environment.get("HOME") ~ /Library/Application Support/; } --- I really wish it could be possible to buy and setup OSX on any hardware...I will never buy a mac just to test the portability of a couple of projects 1 hour per week... Anyway thx all for your answers.On Friday, 17 July 2015 at 07:14:24 UTC, FreeSlave wrote: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.On Thursday, 16 July 2015 at 21:12:05 UTC, anonymous wrote: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 ?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.
Jul 17 2015
On 2015-07-17 15:27, anonymous wrote:Ok so my sample can be rewritten ---- static this() { version(Win32) p = environment.get("APPDATA"); version(linux) p = "/home/" ~ environment.get("USER"); version(OSX) p = environment.get("HOME") ~ /Library/Application Support/; } ---Ideally you should hard code the values like this. BTW, why don't you use the HOME environment variable on Linux.I really wish it could be possible to buy and setup OSX on any hardware...I will never buy a mac just to test the portability of a couple of projects 1 hour per week...It's possible to run OS X on non-Apple computers, including virtual machines. But this is not the place to discuss this. -- /Jacob Carlborg
Jul 17 2015
On 2015-07-17 09:33, Anonymous wrote: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 ?Yes, that's correct. Some applications skip the "Application Support" directory and creates the "SuperDownloader2015" directory directly in $HOME/Library -- /Jacob Carlborg
Jul 17 2015
On 2015-07-17 09:14, FreeSlave wrote: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.DMD master now has some initial support for Objective-C. -- /Jacob Carlborg
Jul 17 2015
On 2015-07-16 23:12, 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)?They are usually defined as constants in Objective-C. You can read more about it here [1][2][3]. You can also use the CoreServices framework which has a C API [4]. But I think it's deprecated and the preferred way is to use the Objective-C API's. [1] https://developer.apple.com/library/mac/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/AccessingFilesandDirectories/AccessingFilesandDirectories.html#//apple_ref/doc/uid/TP40010672-CH3-SW3 [2] https://developer.apple.com/library/mac/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/AccessingFilesandDirectories/AccessingFilesandDirectories.html#//apple_ref/doc/uid/TP40010672-CH3-SW11 [3] https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/index.html#//apple_ref/c/econst/NSApplicationSupportDirectory [4] http://stackoverflow.com/questions/5123361/finding-library-application-support-from-c -- /Jacob Carlborg
Jul 17 2015