aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DomeKey/XDG.h3
-rw-r--r--DomeKey/XDG.m22
2 files changed, 25 insertions, 0 deletions
diff --git a/DomeKey/XDG.h b/DomeKey/XDG.h
index a633fa7..de020b5 100644
--- a/DomeKey/XDG.h
+++ b/DomeKey/XDG.h
@@ -10,4 +10,7 @@
@interface XDG : NSObject
++ (NSURL *)dataPath;
++ (NSURL *)domeKeyDataPath;
+
@end
diff --git a/DomeKey/XDG.m b/DomeKey/XDG.m
index 5d2b4d1..5127739 100644
--- a/DomeKey/XDG.m
+++ b/DomeKey/XDG.m
@@ -8,6 +8,28 @@
#import "XDG.h"
+static NSString * const DOME_KEY_DIR = @"dome-key";
+
@implementation XDG
++ (NSURL *)dataPath
+{
+ NSString *xdg_data_home = [[[NSProcessInfo processInfo] environment]
+ objectForKey:@"XDG_DATA_HOME"];
+
+ if (!xdg_data_home) {
+ // xdg_data_home = @"~/.local/share";
+ xdg_data_home = [@"~/.local/share" stringByExpandingTildeInPath];
+ }
+
+ return [NSURL fileURLWithPath:xdg_data_home isDirectory:YES];
+}
+
++ (NSURL *)domeKeyDataPath
+{
+ return [[self dataPath]
+ URLByAppendingPathComponent:DOME_KEY_DIR
+ isDirectory:YES];
+}
+
@end