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

Reply via email to