moar checking

This commit is contained in:
folecr 2013-08-01 17:44:14 -07:00
parent 952cefa036
commit 8e386cf0bc
1 changed files with 17 additions and 9 deletions

View File

@ -154,17 +154,25 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char*
if (fullPath[0] != '/') if (fullPath[0] != '/')
{ {
string fullPath(filename);
// fullPathForFilename is not thread safe. // fullPathForFilename is not thread safe.
if (! forAsync) if (forAsync) {
{ LOGD("Async loading not supported. fullPathForFilename is not thread safe.");
fullPath = fullPathForFilename(filename); return NULL;
} }
const char* relativepath = fullPath.c_str(); string fullPath = fullPathForFilename(filename);
LOGD("full path = %s", fullPath.c_str());
string relativePath = string();
size_t position = fullPath.find("assets/");
if (0 == position) {
// "assets/" is at the beginning of the path and we don't want it // "assets/" is at the beginning of the path and we don't want it
relativepath += strlen("assets/"); relativePath += fullPath.substr(strlen("assets/"));
} else {
relativePath += fullPath;
}
LOGD("relative path = %s", relativePath.c_str());
if (NULL == FileUtilsAndroid::assetmanager) { if (NULL == FileUtilsAndroid::assetmanager) {
LOGD("... FileUtilsAndroid::assetmanager is NULL"); LOGD("... FileUtilsAndroid::assetmanager is NULL");
@ -174,10 +182,10 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char*
// read asset data // read asset data
AAsset* asset = AAsset* asset =
AAssetManager_open(FileUtilsAndroid::assetmanager, AAssetManager_open(FileUtilsAndroid::assetmanager,
relativepath, relativePath.c_str(),
AASSET_MODE_UNKNOWN); AASSET_MODE_UNKNOWN);
if (NULL == asset) { if (NULL == asset) {
LOGD("asset : is NULL"); LOGD("asset is NULL");
return NULL; return NULL;
} }