@@ -89,7 +89,7 @@ FileUtilsAndroid::~FileUtilsAndroid()
89
89
bool FileUtilsAndroid::init ()
90
90
{
91
91
_defaultResRootPath = ASSETS_FOLDER_NAME;
92
-
92
+
93
93
std::string assetsPath (getApkPath ());
94
94
if (assetsPath.find (" /obb/" ) != std::string::npos)
95
95
{
@@ -165,9 +165,16 @@ bool FileUtilsAndroid::isFileExistInternal(const std::string& strFilePath) const
165
165
{
166
166
const char * s = strFilePath.c_str ();
167
167
168
+ CCLOG (" [FileUtilsAndroid::isFileExistInternal] [steve] _defaultResRootPath: %s" , _defaultResRootPath.c_str ());
169
+
168
170
// Found "assets/" at the beginning of the path and we don't want it
169
- if (strFilePath.find (_defaultResRootPath) == 0 ) s += _defaultResRootPath.length ();
170
-
171
+ if (strFilePath.find (_defaultResRootPath) == 0 ) {
172
+ CCLOG (" [steve] strFilePath: %s" , strFilePath.c_str ());
173
+ s += _defaultResRootPath.length ();
174
+ }
175
+
176
+ CCLOG (" [FileUtilsAndroid::isFileExistInternal] [steve] find in apk dirPath(%s)" , s);
177
+
171
178
if (obbfile && obbfile->fileExists (s))
172
179
{
173
180
bFound = true ;
@@ -180,7 +187,7 @@ bool FileUtilsAndroid::isFileExistInternal(const std::string& strFilePath) const
180
187
bFound = true ;
181
188
AAsset_close (aa);
182
189
} else {
183
- // CCLOG("[AssetManager] ... in APK %s, found = false!", strFilePath.c_str());
190
+ CCLOG (" [FileUtilsAndroid::isFileExistInternal] [steve] [AssetManager] ... in APK %s, found = false!" , strFilePath.c_str ());
184
191
}
185
192
}
186
193
}
@@ -204,11 +211,11 @@ bool FileUtilsAndroid::isDirectoryExistInternal(const std::string& dirPath) cons
204
211
}
205
212
206
213
const char * s = dirPath.c_str ();
207
-
214
+
208
215
// find absolute path in flash memory
209
216
if (s[0 ] == ' /' )
210
217
{
211
- CCLOG (" find in flash memory dirPath(%s)" , s);
218
+ CCLOG (" [FileUtilsAndroid::isDirectoryExistInternal] find in flash memory dirPath(%s)" , s);
212
219
struct stat st;
213
220
if (stat (s, &st) == 0 )
214
221
{
@@ -219,7 +226,7 @@ bool FileUtilsAndroid::isDirectoryExistInternal(const std::string& dirPath) cons
219
226
{
220
227
// find it in apk's assets dir
221
228
// Found "assets/" at the beginning of the path and we don't want it
222
- CCLOG (" find in apk dirPath(%s)" , s);
229
+ CCLOG (" [FileUtilsAndroid::isDirectoryExistInternal] find in apk dirPath(%s)" , s);
223
230
if (dirPath.find (ASSETS_FOLDER_NAME) == 0 )
224
231
{
225
232
s += ASSETS_FOLDER_NAME_LENGTH;
@@ -234,7 +241,7 @@ bool FileUtilsAndroid::isDirectoryExistInternal(const std::string& dirPath) cons
234
241
}
235
242
}
236
243
}
237
-
244
+
238
245
return false ;
239
246
}
240
247
@@ -285,32 +292,36 @@ FileUtils::Status FileUtilsAndroid::getContents(const std::string& filename, Res
285
292
286
293
string fullPath = fullPathForFilename (filename);
287
294
288
- if (fullPath[0 ] == ' /' )
295
+ if (fullPath[0 ] == ' /' ) {
289
296
return FileUtils::getContents (fullPath, buffer);
297
+ }
290
298
291
299
string relativePath = string ();
292
300
size_t position = fullPath.find (apkprefix);
293
301
if (0 == position) {
302
+ CCLOG (" [sctest] find in apk dirPath(%s)" , fullPath.c_str ());
294
303
// "assets/" is at the beginning of the path and we don't want it
295
304
relativePath += fullPath.substr (apkprefix.size ());
296
305
} else {
297
306
relativePath = fullPath;
298
307
}
299
-
308
+
309
+ CCLOG (" [sctest] relativePath: %s" , relativePath.c_str ());
310
+
300
311
if (obbfile)
301
312
{
302
313
if (obbfile->getFileData (relativePath, buffer))
303
314
return FileUtils::Status::OK;
304
315
}
305
316
306
317
if (nullptr == assetmanager) {
307
- LOGD (" ... FileUtilsAndroid::assetmanager is nullptr" );
318
+ LOGD (" [sctest] ... FileUtilsAndroid::assetmanager is nullptr" );
308
319
return FileUtils::Status::NotInitialized;
309
320
}
310
321
311
322
AAsset* asset = AAssetManager_open (assetmanager, relativePath.data (), AASSET_MODE_UNKNOWN);
312
323
if (nullptr == asset) {
313
- LOGD (" asset is nullptr" );
324
+ LOGD (" [sctest] asset is nullptr: %s " , relativePath. c_str () );
314
325
return FileUtils::Status::OpenFailed;
315
326
}
316
327
@@ -326,6 +337,7 @@ FileUtils::Status FileUtilsAndroid::getContents(const std::string& filename, Res
326
337
return FileUtils::Status::ReadFailed;
327
338
}
328
339
340
+ CCLOG (" [sctest] file found OK" , relativePath.c_str ());
329
341
return FileUtils::Status::OK;
330
342
}
331
343
0 commit comments