]> git.tdb.fi Git - libs/core.git/blob - source/fs/osx/cfdir.m
4dd4b4bd8f68018767dcee4304c1bcaf874676b5
[libs/core.git] / source / fs / osx / cfdir.m
1 #import <Foundation/NSPathUtilities.h>
2
3 unsigned get_home_dir(char *buf, unsigned size)
4 {
5         NSString *path = NSHomeDirectory();
6         if(![path getCString:buf maxLength:size encoding:NSUTF8StringEncoding])
7                 return 0;
8
9         return [path lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
10 }
11
12 unsigned get_application_support_dir(char *buf, unsigned size)
13 {
14         NSArray *dirs = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
15         if(![dirs count])
16                 return 0;
17
18         NSString *path = [dirs objectAtIndex:0];
19         if(![path getCString:buf maxLength:size encoding:NSUTF8StringEncoding])
20                 return 0;
21
22         return [path lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
23 }