2010-06-03 19:51:59 +00:00
|
|
|
#include "fileops.hpp"
|
2010-06-05 01:44:05 +00:00
|
|
|
#include <boost/filesystem.hpp>
|
2010-06-25 01:24:16 +00:00
|
|
|
#include <string>
|
|
|
|
|
2010-06-03 23:40:23 +00:00
|
|
|
bool isFile(const char *name)
|
|
|
|
{
|
2010-06-05 01:44:05 +00:00
|
|
|
boost::filesystem::path cfg_file_path(name);
|
|
|
|
return boost::filesystem::exists(cfg_file_path);
|
2010-06-03 19:51:59 +00:00
|
|
|
}
|
2010-06-25 01:24:16 +00:00
|
|
|
|
2010-07-07 08:07:15 +00:00
|
|
|
#ifdef __MACOSX__
|
2010-06-25 01:24:16 +00: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
|