Do not crash when importing non-utf8 .txt files

This commit is contained in:
luboslenco
2023-05-14 19:12:44 +02:00
parent c618aaa995
commit 5759780e09
3 changed files with 9 additions and 23 deletions
-20
View File
@@ -1,20 +0,0 @@
let import_txt = function(path, done) {
iron.Data.getBlob(path, function(b) {
var filename = path.split('\\').pop().split('/').pop();
arm.UIBox.showMessage(filename, b.toString(), true);
arm.UIBox.clickToHide = false;
iron.Data.deleteBlob(path);
});
}
let plugin = new arm.Plugin();
let formats = arm.Path.textureFormats;
let importers = arm.Path.textureImporters;
formats.push("txt");
importers.h["txt"] = import_txt;
plugin.delete = function() {
formats.splice(formats.indexOf("txt"), 1);
importers.h["txt"] = null;
};
@@ -2,9 +2,14 @@
let import_txt = function(path, done) {
iron.Data.getBlob(path, function(b) {
var filename = path.split('\\').pop().split('/').pop();
arm.UIBox.showMessage(filename, b.toString(), true);
arm.UIBox.clickToHide = false;
iron.Data.deleteBlob(path);
try {
arm.UIBox.showMessage(filename, b.toString(), true);
arm.UIBox.clickToHide = false;
iron.Data.deleteBlob(path);
}
catch(e) {
console.error(e);
}
});
}
+1
View File
@@ -21,6 +21,7 @@ project.addShaders("Shaders/*.glsl", { embed: flags.snapshot });
project.addAssets("Assets/*", { destination: "data/{name}", embed: flags.snapshot });
project.addAssets("Assets/locale/*", { destination: "data/locale/{name}" });
project.addAssets("Assets/licenses/**", { destination: "data/licenses/{name}" });
project.addAssets("Assets/plugins/*", { destination: "data/plugins/{name}" });
project.addAssets("Assets/themes/*.json", { destination: "data/themes/{name}" });
if (flags.snapshot) {