1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-03-01 21:59:12 -05:00
parent f495595da4
commit d279c70606
346 changed files with 3516 additions and 2970 deletions

View File

@@ -26,6 +26,12 @@ public class Byte_ {
;
public static byte cast_(Object o) {try {return (Byte)o;} catch (Exception e) {throw Err_.type_mismatch_exc_(e, byte.class, o);}}
public static byte parse_(String raw) {return Byte.parseByte(raw);}
public static byte parse_or_(String raw, byte or) {
if (raw == null) return or;
try {
return parse_(raw);
} catch (Exception e) {Err_.Noop(e); return or;}
}
public static byte By_int(int v) {return v > 127 ? (byte)(v - 256) : (byte)v;} // PERF?: (byte)(v & 0xff)
public static int Xto_int(byte v) {return v < 0 ? (int)v + 256 : v;}
public static String Xto_str(byte v) {return new Byte(v).toString();}

View File

@@ -47,7 +47,8 @@ public class IoEngine_system extends IoEngine_base {
DeleteFil_lang(fil, url);
}
@Override public boolean ExistsFil_api(Io_url url) {
return new File(url.Xto_api()).exists();
File f = new File(url.Xto_api());
return f.exists();
}
@Override public void SaveFilText_api(IoEngine_xrg_saveFilStr mpo) {
Io_url url = mpo.Url();
@@ -85,7 +86,11 @@ public class IoEngine_system extends IoEngine_base {
@SuppressWarnings("resource")
@Override public String LoadFilStr(IoEngine_xrg_loadFilStr args) {
Io_url url = args.Url();
boolean file_exists = ExistsFil_api(url); // check if file exists first to avoid throwing exception; note that most callers pass Missing_ignored; DATE:2015-02-24
if (!file_exists) {
if (args.MissingIgnored()) return "";
else throw Err_Fil_NotFound(url);
}
// get reader for file
InputStream stream = null;
try {stream = new FileInputStream(url.Xto_api());}
@@ -600,7 +605,8 @@ class Io_stream_rdr_http implements Io_stream_rdr {
if (read_failed) {
}
else {
prog_dlg.Log_wtr().Log_msg_to_url_fmt(session_fil, "download pass: src='~{0}' trg='~{1}'", src_str, xrg.Trg().Raw());
if (prog_dlg != null)
prog_dlg.Log_wtr().Log_msg_to_url_fmt(session_fil, "download pass: src='~{0}' trg='~{1}'", src_str, xrg.Trg().Raw());
xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_pass);
}
xrg.Prog_running_(false);