chdir to data directory on mac
May change this later if I decide to go back to using objective-c (or swift?) later to reimplement the rest of the mac features
This commit is contained in:
parent
cc93479c4b
commit
655f4bb6d0
@ -28,6 +28,10 @@
|
||||
#ifndef WIN
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef MACOSX
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include "Format.h"
|
||||
|
||||
@ -546,6 +550,23 @@ void SigHandler(int signal)
|
||||
}
|
||||
}
|
||||
|
||||
void ChdirToDataDirectory()
|
||||
{
|
||||
#ifdef MACOSX
|
||||
FSRef ref;
|
||||
OSType folderType = kApplicationSupportFolderType;
|
||||
char path[PATH_MAX];
|
||||
|
||||
FSFindFolder( kUserDomain, folderType, kCreateFolder, &ref );
|
||||
|
||||
FSRefMakePath( &ref, (UInt8*)&path, PATH_MAX );
|
||||
|
||||
const char *tptPath = (std::string(path) + "/The Powder Toy").c_str();
|
||||
mkdir(tptPath, 0755);
|
||||
chdir(tptPath);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
#if defined(_DEBUG) && defined(_MSC_VER)
|
||||
@ -563,6 +584,8 @@ int main(int argc, char * argv[])
|
||||
#else
|
||||
chdir(arguments["ddir"].c_str());
|
||||
#endif
|
||||
else
|
||||
ChdirToDataDirectory();
|
||||
|
||||
scale = Client::Ref().GetPrefInteger("Scale", 1);
|
||||
resizable = Client::Ref().GetPrefBool("Resizable", false);
|
||||
|
Loading…
Reference in New Issue
Block a user