Improve file handling on android
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package arm.sys;
|
||||
|
||||
import haxe.macro.Context;
|
||||
|
||||
class BuildMacros {
|
||||
|
||||
#if krom_android
|
||||
macro public static function readDirectory(path: String): ExprOf<Array<String>> {
|
||||
return Context.makeExpr(sys.FileSystem.readDirectory(path), Context.currentPos());
|
||||
}
|
||||
#end
|
||||
}
|
||||
@@ -19,12 +19,29 @@ class File {
|
||||
static var cloud: Map<String, Array<String>> = null;
|
||||
static var cloudSizes: Map<String, Int> = null;
|
||||
|
||||
#if krom_android
|
||||
static var internal: Map<String, Array<String>> = null; // .apk contents
|
||||
#end
|
||||
|
||||
public static function readDirectory(path: String, foldersOnly = false): Array<String> {
|
||||
if (path.startsWith("cloud")) {
|
||||
if (cloud == null) initCloud();
|
||||
var files = cloud.get(path.replace("\\", "/"));
|
||||
return files != null ? files : [];
|
||||
}
|
||||
#if krom_android
|
||||
path = path.replace("//", "/");
|
||||
if (internal == null) {
|
||||
internal = [];
|
||||
internal.set("/data/plugins", BuildMacros.readDirectory("krom/data/plugins"));
|
||||
internal.set("/data/export_presets", BuildMacros.readDirectory("krom/data/export_presets"));
|
||||
internal.set("/data/keymap_presets", BuildMacros.readDirectory("krom/data/keymap_presets"));
|
||||
internal.set("/data/locale", BuildMacros.readDirectory("krom/data/locale"));
|
||||
internal.set("/data/meshes", BuildMacros.readDirectory("krom/data/meshes"));
|
||||
internal.set("/data/themes", BuildMacros.readDirectory("krom/data/themes"));
|
||||
}
|
||||
if (internal.exists(path)) return internal.get(path);
|
||||
#end
|
||||
return Krom.readDirectory(path, foldersOnly).split("\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,10 @@ class TabBrowser {
|
||||
});
|
||||
hpath.text = hpath.text.substr(0, hpath.text.lastIndexOf(Path.sep));
|
||||
}
|
||||
known = hpath.text.indexOf(".") > 0;
|
||||
known = hpath.text.substr(hpath.text.lastIndexOf(Path.sep)).indexOf(".") > 0;
|
||||
#if krom_android
|
||||
if (hpath.text.endsWith(".armorpaint")) known = false;
|
||||
#end
|
||||
|
||||
var bottomY = ui._y;
|
||||
var _h = ui._h;
|
||||
|
||||
@@ -259,7 +259,7 @@ class UIFiles {
|
||||
#if krom_windows
|
||||
"C:\\Users"
|
||||
#elseif krom_android
|
||||
"/sdcard"
|
||||
"/sdcard/Android/data/org.armorpaint/files"
|
||||
#elseif krom_darwin
|
||||
"/Users"
|
||||
#else
|
||||
|
||||
@@ -4,11 +4,11 @@ import haxe.macro.Context;
|
||||
|
||||
class BuildMacros {
|
||||
|
||||
macro public static function date():ExprOf<String> {
|
||||
macro public static function date(): ExprOf<String> {
|
||||
return Context.makeExpr(Date.now().toString(), Context.currentPos());
|
||||
}
|
||||
|
||||
macro public static function sha():ExprOf<String> {
|
||||
macro public static function sha(): ExprOf<String> {
|
||||
var proc = new sys.io.Process("git", ["log", "--pretty=format:'%h'", "-n", "1"]);
|
||||
return Context.makeExpr(proc.stdout.readLine(), Context.currentPos());
|
||||
}
|
||||
|
||||
+1
-4
@@ -39,6 +39,7 @@ project.addDefine("js-es=6");
|
||||
project.addParameter("--macro include('arm.node.brush')");
|
||||
project.addDefine("kha_no_ogg");
|
||||
project.addDefine("zui_translate");
|
||||
project.addDefine("arm_data_dir");
|
||||
project.addDefine("arm_ltc");
|
||||
project.addDefine("arm_appwh");
|
||||
project.addDefine("arm_skip_envmap");
|
||||
@@ -49,10 +50,6 @@ project.addDefine("arm_particles");
|
||||
// project.addDefine("arm_physics");
|
||||
// project.addDefine("arm_skin");
|
||||
|
||||
if (!android) {
|
||||
project.addDefine("arm_data_dir");
|
||||
}
|
||||
|
||||
if (android) {
|
||||
project.addDefine("krom_android");
|
||||
project.addDefine("kha_android");
|
||||
|
||||
Reference in New Issue
Block a user