std::string Platform::DataFile(const std::string& fileName)
{
std::stringstream stream("");
char path[PATH_MAX]; // Will store the absolute directory to the Resources directory
// Obtain a reference to the main application bundle
CFBundleRef mainBundle = CFBundleGetMainBundle();
// Grab the Resources directory
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
if(!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (unsigned char*)path, PATH_MAX))
{
std::cerr << "Error obtaining a file-system representation of the Resources URL!" << std::endl;
return "";
}
CFRelease(resourcesURL);
stream << path << "/";
// Append the File URL
stream << fileName;
return stream.str();
}