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-07-12 21:10:02 -04:00
commit 794b5a232f
3099 changed files with 238212 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.fsys; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.core.primitives.*; import gplx.xowa.users.*;
public class Xoa_fsys_eval implements Bry_fmtr_eval_mgr {
private final Xoa_fsys_mgr app_fsys_mgr; private final Xou_fsys_mgr usr_fsys_mgr;
public Xoa_fsys_eval(Xoa_fsys_mgr app_fsys_mgr, Xou_fsys_mgr usr_fsys_mgr) {this.app_fsys_mgr = app_fsys_mgr; this.usr_fsys_mgr = usr_fsys_mgr;}
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled = true;
public byte[] Eval(byte[] cmd) {
Object o = hash.Get_by_bry(cmd); if (o == null) return null;
byte val = ((Byte_obj_val)o).Val();
switch (val) {
case Tid_xowa_root_dir: return app_fsys_mgr.Root_dir().RawBry();
case Tid_bin_plat_dir: return app_fsys_mgr.Bin_plat_dir().RawBry();
case Tid_user_temp_dir: return usr_fsys_mgr.App_temp_dir().RawBry();
case Tid_user_cfg_dir: return usr_fsys_mgr.App_data_cfg_dir().RawBry();
default: throw Exc_.new_unhandled(val);
}
}
private static final byte Tid_bin_plat_dir = 0, Tid_user_temp_dir = 1, Tid_xowa_root_dir = 2, Tid_user_cfg_dir = 3;
private static final Hash_adp_bry hash = Hash_adp_bry.ci_ascii_()
.Add_str_byte("bin_plat_dir" , Tid_bin_plat_dir)
.Add_str_byte("user_temp_dir" , Tid_user_temp_dir)
.Add_str_byte("xowa_root_dir" , Tid_xowa_root_dir)
.Add_str_byte("user_cfg_dir" , Tid_user_cfg_dir)
;
}

View File

@@ -0,0 +1,52 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.fsys; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Xoa_fsys_mgr implements GfoInvkAble {
public Xoa_fsys_mgr(String plat_name, Io_url root_dir, Io_url wiki_dir, Io_url file_dir, Io_url css_dir) {
this.root_dir = root_dir;
this.wiki_dir = wiki_dir;
this.file_dir = file_dir;
this.css_dir = css_dir;
this.bin_plat_dir = root_dir.GenSubDir("bin").GenSubDir(plat_name);
this.bin_any_dir = root_dir.GenSubDir("bin").GenSubDir("any");
this.bin_xowa_dir = bin_any_dir.GenSubDir("xowa");
this.bin_xtns_dir = bin_any_dir.GenSubDir_nest("xowa", "xtns");
this.cfg_lang_core_dir = bin_any_dir.GenSubDir_nest("xowa", "cfg", "lang", "core");
this.cfg_wiki_core_dir = bin_any_dir.GenSubDir_nest("xowa", "cfg", "wiki", "core");
}
public Io_url Root_dir() {return root_dir;} private final Io_url root_dir;
public Io_url Wiki_dir() {return wiki_dir;} private final Io_url wiki_dir;
public Io_url File_dir() {return file_dir;} private final Io_url file_dir;
public Io_url Css_dir() {return css_dir;} private final Io_url css_dir;
public Io_url Bin_plat_dir() {return bin_plat_dir;} private final Io_url bin_plat_dir;
public Io_url Bin_any_dir() {return bin_any_dir;} private final Io_url bin_any_dir;
public Io_url Bin_xowa_dir() {return bin_xowa_dir;} private final Io_url bin_xowa_dir;
public Io_url Bin_xtns_dir() {return bin_xtns_dir;} private final Io_url bin_xtns_dir;
public Io_url Cfg_lang_core_dir() {return cfg_lang_core_dir;} private final Io_url cfg_lang_core_dir;
public Io_url Cfg_wiki_core_dir() {return cfg_wiki_core_dir;} private final Io_url cfg_wiki_core_dir;
public Io_url Bin_data_os_cfg_fil() {return bin_plat_dir.GenSubFil_nest("xowa", "cfg", Xoa_gfs_mgr.Cfg_os);}
public Io_url Wiki_css_dir(String wiki) {return css_dir.GenSubDir_nest(wiki, "html");} // EX: /xowa/temp/simple.wikipedia.org/html/xowa_common.css
public Io_url Wiki_file_dir(String wiki) {return file_dir.GenSubDir_nest(wiki);} // EX: /xowa/temp/simple.wikipedia.org/orig/
public void Init_by_app(GfoInvkAble app_mgr_invk) {this.app_mgr_invk = app_mgr_invk;} private GfoInvkAble app_mgr_invk; // for gfs and app.launcher
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_apps)) return app_mgr_invk;
else if (ctx.Match(k, Invk_root_dir)) return root_dir;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_apps = "apps", Invk_root_dir = "root_dir";
}