};
};
+ if_arch "darwin"
+ {
+ build_info
+ {
+ library "Foundation.framework";
+ };
+ };
+
feature "zlib" "Support compression with zlib"
{
default "yes";
--- /dev/null
+#import <Foundation/NSPathUtilities.h>
+
+unsigned get_home_dir(char *buf, unsigned size)
+{
+ NSString *path = NSHomeDirectory();
+ if(![path getCString:buf maxLength:size encoding:NSUTF8StringEncoding])
+ return 0;
+
+ return [path lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
+}
+
+unsigned get_application_support_dir(char *buf, unsigned size)
+{
+ NSArray *dirs = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
+ if(![dirs count])
+ return 0;
+
+ NSString *path = [dirs objectAtIndex:0];
+ if(![path getCString:buf maxLength:size encoding:NSUTF8StringEncoding])
+ return 0;
+
+ return [path lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
+}
--- /dev/null
+#include "dir.h"
+
+using namespace std;
+
+extern "C" unsigned get_home_dir(char *, unsigned);
+extern "C" unsigned get_application_support_dir(char *, unsigned);
+
+namespace Msp {
+namespace FS {
+
+Path get_home_dir()
+{
+ char buf[1024];
+ unsigned len = ::get_home_dir(buf, sizeof(buf));
+ if(len)
+ return string(buf, len);
+
+ const char *home = getenv("HOME");
+ if(home)
+ return home;
+
+ return ".";
+}
+
+Path get_user_data_dir(const string &appname)
+{
+ char buf[1024];
+ unsigned len = get_application_support_dir(buf, sizeof(buf));
+ if(len)
+ return Path(string(buf, len))/appname;
+ return get_home_dir()/"Library"/"Application Support"/appname;
+}
+
+} // namespace FS
+} // namespace Msp