diff --git a/project/src/utils/ByteArray.cpp b/project/src/utils/ByteArray.cpp index af04c7b0c..7ffdc48a1 100644 --- a/project/src/utils/ByteArray.cpp +++ b/project/src/utils/ByteArray.cpp @@ -126,11 +126,29 @@ FILE *OpenOverwrite(const char *inName); // [ddc] extern int gFixedOrientation; #elif defined(HX_MACOS) -} // close namespace nme -extern "C" FILE *OpenRead(const char *inName); -extern "C" bool GetBundleFilename(const char *inName, char *outBuffer,int inBufSize); -extern "C" FILE *OpenOverwrite(const char *inName); -namespace nme { +#include +FILE *OpenRead(const char *inName) +{ + FILE *result = fopen(inName,"rb"); + if (!result) { + CFStringRef str = CFStringCreateWithCString(NULL, inName, kCFStringEncodingUTF8); + CFURLRef path = CFBundleCopyResourceURL(CFBundleGetMainBundle(), str, NULL, NULL); + CFRelease(str); + if (path) { + str = CFURLCopyPath(path); + CFIndex maxSize = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str),kCFStringEncodingUTF8); + char *buffer = (char *)malloc(maxSize); + if (CFStringGetCString(str, buffer, maxSize, kCFStringEncodingUTF8)) { + result = fopen(buffer,"rb"); + free(buffer); + } + CFRelease(str); + CFRelease(path); + } + } + return result; +} +#define OpenOverwrite(x) fopen(x,"wb") #else #ifdef TIZEN extern int gFixedOrientation;