GC removed, readme updated
[libs.git] / src / Sylph / OS / MacOSAppSelf.cpp
blob7b0a6c0e345a6fc29f2533f3a2d72ab86adc5c00
1 #include "MacOSAppSelf.h"
2 #include "../Core/File.h"
4 #ifdef SYLPH_OS_MACOSX
6 #include <string>
7 #include <pwd.h>
9 SYLPH_BEGIN_NAMESPACE
11 MacOSAppSelf::MacOSAppSelf(int argc, char * argv[], char * apple[]) {
12 _location= String(apple[0]);
15 const File& MacOSAppSelf::bundle() {
16 static File f = File(_location).parent().parent().parent();
17 return f;
20 const File& MacOSAppSelf::resourceDir() {
21 static File f = bundle() / "Contents/Resources";
22 return f;
25 const File MacOSAppSelf::resource(String rsc) {
26 return resourceDir() / rsc;
29 const File& MacOSAppSelf::libraryDir() {
30 static File f = bundle() / "Contents/Frameworks";
31 return f;
34 const File& MacOSAppSelf::pluginDir() {
35 static File f = bundle() / "Contents/Plugins";
36 return f;
39 const File& MacOSAppSelf::plugindisabledDir() {
40 static File f = bundle() / "Contents/Plugins-Disabled";
41 return f;
44 const File& MacOSAppSelf::systemLibraryDir() {
45 static File f = "/Library";
46 return f;
49 const File& MacOSAppSelf::systemSettings() {
50 static File f = "/Library/Preferences/" + appName() + ".prp";
51 return f;
54 const File& MacOSAppSelf::systemSettingsDir() {
55 static File f = "/Library/Preferences";
56 return f;
59 const File& MacOSAppSelf::systemPluginDir() {
60 static File f = systemResource("Plugins");
61 return f;
64 const File& MacOSAppSelf::systemPluginDisabledDir() {
65 static File f = systemResource("Plugins-Disabled");
66 return f;
69 const File& MacOSAppSelf::systemResourceDir() {
70 static File f = "/Library/Application Support/"+appName();
71 return f;
74 const File MacOSAppSelf::systemResource(String rsc) {
75 return systemResourceDir() / rsc;
78 const File& MacOSAppSelf::userHome() {
79 static File f = getpwuid(geteuid())->pw_dir;
80 return f;
83 const File& MacOSAppSelf::userLibraryDir() {
84 static File f = userHome() / "Library";
85 return f;
88 const File& MacOSAppSelf::userSettings() {
89 static File f = userLibraryDir() / ("Preferences/"+appName() + ".prp");
90 return f;
93 const File& MacOSAppSelf::userSettingsDir() {
94 static File f = userLibraryDir() / "Preferences";
95 return f;
98 const File& MacOSAppSelf::userPluginDir() {
99 static File f = userResource("Plugins");
100 return f;
103 const File& MacOSAppSelf::userPluginDisabledDir() {
104 static File f = userResource("Plugins-Disabled");
105 return f;
108 const File& MacOSAppSelf::userResourceDir() {
109 static File f = userLibraryDir() / ("Application Support/" + appName());
110 return f;
113 const File MacOSAppSelf::userResource(String rsc) {
114 return userResourceDir() / rsc;
117 const File& MacOSAppSelf::prefix() {
118 static File f = File(_location).parent().parent();
119 return f;
122 SYLPH_END_NAMESPACE
124 #endif // SYLPH_OS_MACOSX