|
|
@@ -745,73 +745,65 @@ bool FileSystem::SetLastModifiedTime(const String& fileName, unsigned newTime)
|
|
|
|
|
|
#if defined(ANDROID)
|
|
|
|
|
|
-extern "C" {
|
|
|
-
|
|
|
-#include <android/asset_manager.h>
|
|
|
-#include <android/asset_manager_jni.h>
|
|
|
-
|
|
|
-static AAssetManager *gAssetManager = NULL;
|
|
|
-
|
|
|
-void Java_com_github_atomic_Atomic_nativeSetAssetManager(JNIEnv *env, jobject thiz, jobject assetManageObject)
|
|
|
-{
|
|
|
- gAssetManager = AAssetManager_fromJava(env, assetManageObject);
|
|
|
-}
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-// TODO: AAssetManager_openDir doesn't support subdirectories :/
|
|
|
+// the android asset manager is quite limited, so use a manifest instead
|
|
|
+static Vector<String> _atomicManifest;
|
|
|
|
|
|
void FileSystem::ScanDirInternal(Vector<String>& result, String path, const String& startPath,
|
|
|
const String& filter, unsigned flags, bool recursive) const
|
|
|
{
|
|
|
- if (!gAssetManager)
|
|
|
+
|
|
|
+ if (!_atomicManifest.Size())
|
|
|
{
|
|
|
- LOGERROR("FileSystem::ScanDirInternal - AssetManager Not Set");
|
|
|
- return;
|
|
|
- }
|
|
|
+ File file(context_, "/apk/AtomicManifest", FILE_READ);
|
|
|
+ if (!file.IsOpen())
|
|
|
+ {
|
|
|
+ LOGERRORF("Unabled to open AtomicManifest");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
+ String manifest = file.ReadString();
|
|
|
+ _atomicManifest = manifest.Split(';');
|
|
|
+ }
|
|
|
|
|
|
if (path.StartsWith("/apk/"))
|
|
|
path = path.Substring(5);
|
|
|
|
|
|
- // Asset Manager is very sensitive on paths
|
|
|
path.Replace(String("//"), String("/"));
|
|
|
path = RemoveTrailingSlash(path);
|
|
|
|
|
|
- //LOGINFOF("Scanning: %s", path.CString());
|
|
|
+ // first path is the Data/CoreData/AtomicResources folder
|
|
|
+ path = path.Substring(path.Find('/') + 1) + "/";
|
|
|
|
|
|
String filterExtension = filter.Substring(filter.Find('.'));
|
|
|
if (filterExtension.Contains('*'))
|
|
|
- filterExtension.Clear();
|
|
|
-
|
|
|
- String deltaPath;
|
|
|
- if (path.Length() > startPath.Length())
|
|
|
- deltaPath = path.Substring(startPath.Length());
|
|
|
-
|
|
|
- AAssetDir* assetDir = AAssetManager_openDir(gAssetManager, path.CString());
|
|
|
-
|
|
|
- const char* _filename = (const char*)NULL;
|
|
|
+ filterExtension.Clear();
|
|
|
|
|
|
- while ((_filename = AAssetDir_getNextFileName(assetDir)) != NULL) {
|
|
|
+ for (unsigned i = 0; i < _atomicManifest.Size(); i++ )
|
|
|
+ {
|
|
|
+ const String& file = _atomicManifest[i];
|
|
|
+ String filePath = GetPath(file);
|
|
|
+ String filename = GetFileNameAndExtension(file);
|
|
|
|
|
|
- String filename = _filename;
|
|
|
+ //LOGINFOF("%s : %s : %s", path.CString(), filePath.CString(), filename.CString());
|
|
|
|
|
|
- if (flags & SCAN_FILES)
|
|
|
+ if (filePath.StartsWith(path))
|
|
|
{
|
|
|
- if (filterExtension.Empty() || filename.EndsWith(filterExtension))
|
|
|
- result.Push(deltaPath + filename);
|
|
|
- }
|
|
|
+ if (flags & SCAN_FILES)
|
|
|
+ {
|
|
|
+ if (filterExtension.Empty() || filename.EndsWith(filterExtension))
|
|
|
+ {
|
|
|
+ String deltaPath;
|
|
|
|
|
|
- //LOGINFOF("filename: %s", filename.CString());
|
|
|
+ if (path.Length() > startPath.Length())
|
|
|
+ deltaPath = path.Substring(startPath.Length());
|
|
|
|
|
|
+ result.Push(deltaPath + GetFileNameAndExtension(file));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- AAssetDir_close(assetDir);
|
|
|
-
|
|
|
- return;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
#else
|
|
|
|
|
|
void FileSystem::ScanDirInternal(Vector<String>& result, String path, const String& startPath,
|