From e9592c45c744b1da105adaa81cfa09d57c74b966 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 17 Apr 2013 11:56:32 -0700 Subject: [PATCH] fix reference to resources directory on OS X --- interface/src/Audio.cpp | 4 ++-- interface/src/Head.cpp | 2 +- libraries/shared/src/SharedUtil.cpp | 3 ++- libraries/shared/src/SharedUtil.h | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 578e1368c8..997361a378 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -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); diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 658e749eed..7a310b8171 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -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; diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 8fb8645730..97c9b047be 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -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 } diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index f7e639ba43..e70229637a 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -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);