implement mac OS X version of get desktop path

This commit is contained in:
Edward Rudd 2014-01-03 21:52:57 -05:00
parent f72ce6de33
commit bae3d1b036
1 changed files with 30 additions and 2 deletions

View File

@ -1,7 +1,35 @@
#include "config.h"
#include <string>
#import <Foundation/Foundation.h>
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()
{
}
desktopPath = get_desktop_dir();
}