2010-06-03 21:51:59 +02:00
|
|
|
#include "fileops.hpp"
|
2010-06-04 21:44:05 -04:00
|
|
|
#include <boost/filesystem.hpp>
|
2010-06-24 21:24:16 -04:00
|
|
|
#include <string>
|
|
|
|
|
2010-06-03 19:40:23 -04:00
|
|
|
bool isFile(const char *name)
|
|
|
|
{
|
2010-06-04 21:44:05 -04:00
|
|
|
boost::filesystem::path cfg_file_path(name);
|
|
|
|
return boost::filesystem::exists(cfg_file_path);
|
2010-06-03 21:51:59 +02:00
|
|
|
}
|
2010-06-24 21:24:16 -04:00
|
|
|
|
2010-07-07 10:07:15 +02:00
|
|
|
#ifdef __MACOSX__
|
2010-06-24 21:24:16 -04:00
|
|
|
#include <CoreFoundation/CoreFoundation.h>
|
|
|
|
|
|
|
|
std::string macBundlePath()
|
|
|
|
{
|
|
|
|
char path[1024];
|
|
|
|
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
|
|
|
assert(mainBundle);
|
|
|
|
|
|
|
|
CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
|
|
|
|
assert(mainBundleURL);
|
|
|
|
|
|
|
|
CFStringRef cfStringRef = CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
|
|
|
|
assert(cfStringRef);
|
|
|
|
|
|
|
|
CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
|
|
|
|
|
|
|
|
CFRelease(mainBundleURL);
|
|
|
|
CFRelease(cfStringRef);
|
|
|
|
|
|
|
|
return std::string(path);
|
|
|
|
}
|
|
|
|
#endif
|