conditional chdir for OS X resources, revert windows Head changes

This commit is contained in:
Stephen Birarda 2013-03-21 17:02:41 -07:00
parent e2a28b48db
commit 95926cb7fc
5 changed files with 30 additions and 3 deletions

View file

@ -438,7 +438,9 @@ Audio::Audio(Oscilloscope *s, Head *linkedHead)
{
// read the walking sound from the raw file and store it
// in the in memory array
FILE *soundFile = fopen("interface.app/Contents/Resources/audio/walking.raw", "r");
switchToResourcesIfRequired();
FILE *soundFile = fopen("audio/walking.raw", "r");
// get length of file:
std::fseek(soundFile, 0, SEEK_END);

View file

@ -8,11 +8,12 @@
#include <iostream>
#include <glm/glm.hpp>
#include "Head.h"
#include <vector>
#include <lodepng.h>
#include <fstream>
#include <sstream>
#include <SharedUtil.h>
#include "Head.h"
using namespace std;
@ -31,7 +32,7 @@ float browThickness = 0.16;
const float DECAY = 0.1;
char iris_texture_file[] = "interface.app/Contents/Resources/images/green_eye.png";
char iris_texture_file[] = "images/green_eye.png";
vector<unsigned char> iris_texture;
unsigned int iris_texture_width = 512;
@ -77,6 +78,7 @@ Head::Head()
hand = new Hand(glm::vec3(skinColor[0], skinColor[1], skinColor[2]));
if (iris_texture.size() == 0) {
switchToResourcesIfRequired();
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

@ -921,6 +921,7 @@ int main(int argc, char** argv)
}
}
#endif
// Lookup the IP address of things we have hostnames
if (atoi(DOMAIN_IP) == 0) {
struct hostent* pHostInfo;

View file

@ -10,6 +10,10 @@
#include <cstdio>
#include "SharedUtil.h"
#ifdef __APPLE__
#include <CoreFoundation/CoreFoundation.h>
#endif
double usecTimestamp(timeval *time) {
return (time->tv_sec * 1000000.0 + time->tv_usec);
}
@ -55,4 +59,20 @@ int numberOfOnes(unsigned char byte) {
bool oneAtBit(unsigned char byte, int bitIndex) {
return (byte >> (7 - bitIndex) & 1);
}
void switchToResourcesIfRequired() {
#ifdef __APPLE__
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
char path[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) // Error: expected unqualified-id before 'if'
{
// error!
}
CFRelease(resourcesURL); // error: expected constructor, destructor or type conversion before '(' token
chdir(path); // error: expected constructor, destructor or type conversion before '(' token
std::cout << "Current Path: " << path << std::endl; // error: expected constructor, destructor or type conversion before '<<' token
#endif
}

View file

@ -29,4 +29,6 @@ void outputBits(unsigned char byte);
int numberOfOnes(unsigned char byte);
bool oneAtBit(unsigned char byte, int bitIndex);
void switchToResourcesIfRequired();
#endif /* defined(__hifi__SharedUtil__) */