diff --git a/src/platform_osx.mm b/src/platform_osx.mm index 41dc7be..e84f022 100644 --- a/src/platform_osx.mm +++ b/src/platform_osx.mm @@ -1,7 +1,35 @@ #include "config.h" +#include + +#import + +static void ensure_trailing_slash(std::string& path) +{ + if (path.size() && path[path.size()-1] != '/') { + path += "/"; + } +} + +static std::string get_desktop_dir() +{ + std::string ret; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask, YES); + NSString *path = [paths objectAtIndex: 0]; + + ret = [path fileSystemRepresentation]; + + [pool drain]; + + ensure_trailing_slash(ret); + return ret; +} + void Config::setupPaths() { - -} \ No newline at end of file + desktopPath = get_desktop_dir(); +} +