fix reference to resources directory on OS X

This commit is contained in:
Stephen Birarda 2013-04-17 11:56:32 -07:00
parent 0768785cfd
commit e9592c45c7
4 changed files with 6 additions and 5 deletions

View file

@ -444,8 +444,8 @@ Audio::Audio(Oscilloscope *s, Head *linkedHead)
// read the walking sound from the raw file and store it
// in the in memory array
switchToResourcesIfRequired();
FILE *soundFile = fopen("audio/walking.raw", "r");
switchToResourcesParentIfRequired();
FILE *soundFile = fopen("resources/audio/walking.raw", "r");
// get length of file:
std::fseek(soundFile, 0, SEEK_END);

View file

@ -114,7 +114,7 @@ Head::Head() {
springVelocityDecay = 16.0f;
if (iris_texture.size() == 0) {
switchToResourcesIfRequired();
switchToResourcesParentIfRequired();
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
if (error != 0) {
std::cout << "error " << error << ": " << lodepng_error_text(error) << std::endl;

View file

@ -74,7 +74,7 @@ bool oneAtBit(unsigned char byte, int bitIndex) {
return (byte >> (7 - bitIndex) & 1);
}
void switchToResourcesIfRequired() {
void switchToResourcesParentIfRequired() {
#ifdef __APPLE__
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
@ -85,6 +85,7 @@ void switchToResourcesIfRequired() {
CFRelease(resourcesURL);
chdir(path);
chdir("..");
#endif
}

View file

@ -47,7 +47,7 @@ void printVoxelCode(unsigned char* voxelCode);
int numberOfOnes(unsigned char byte);
bool oneAtBit(unsigned char byte, int bitIndex);
void switchToResourcesIfRequired();
void switchToResourcesParentIfRequired();
const char* getCmdOption(int argc, const char * argv[],const char* option);
bool cmdOptionExists(int argc, const char * argv[],const char* option);