public Mustache_doc_itm[] Mustache__subs(String key) { if (String_.Eq(key, "is_dir")) return Mustache_doc_itm_.Ary__bool(is_dir); else if (String_.Eq(key, "dir_cmd_exists")) return Mustache_doc_itm_.Ary__bool(Bry_.Len_gt_0(dir_cmd)); else if (String_.Eq(key, "is_core_xowa")) return Mustache_doc_itm_.Ary__bool(is_core_xowa); else if (String_.Eq(key, "subs")) return subs; return Mustache_doc_itm_.Ary__empty; }
@Override public Xobc_xodir_dir[] Get_dirs(Xoa_app app) { Ordered_hash hash = Ordered_hash_.New(); // add default app dir String default_data_dir = context.getApplicationInfo().dataDir + "/"; String selected = app.User() .User_db_mgr() .Cfg() .Get_app_str_or(Xobc_xodir_cfg.Key__selected_dir, default_data_dir); Xobc_xodir_dir itm = new Xobc_xodir_dir( String_.Eq(selected, default_data_dir), false, Bry_.new_u8(default_data_dir)); hash.Add(default_data_dir, itm); // add "guessed" external dirs Sdcard_detection_strategy[] strategy_ary = new Sdcard_detection_strategy[] { new Strategy__storage_dir(-1), new Strategy__envvar__external_storage(-1), new Strategy__envvar__secondary_storage( -1) // NOTE: needed for BLU-STUDIO C 5+5 LTE; DATE: 2016-06-28 }; int len = strategy_ary.length; String root_rhs = Sdcard_detection_mgr.Get_root_rhs() + "/"; for (int i = 0; i < len; ++i) { Sdcard_detection_strategy strategy = strategy_ary[i]; String[] dir_strs = strategy.Get_dirs(context); for (String dir_str : dir_strs) { if (dir_str == null) continue; dir_str += root_rhs; if (hash.Has(dir_str)) continue; File dir = new File(dir_str); if (!dir.exists()) continue; // dir doesn't exist; don't bother trying to create b/c permission won't be // available at 4.4+ if (!Sdcard_detection_mgr.Dir_is_writeable(dir)) continue; itm = new Xobc_xodir_dir(String_.Eq(selected, dir_str), false, Bry_.new_u8(dir_str)); hash.Add(dir_str, itm); } } // add custom dir String custom = app.User() .User_db_mgr() .Cfg() .Get_app_str_or(Xobc_xodir_cfg.Key__custom_dir, "(choose your own folder)"); itm = new Xobc_xodir_dir(String_.Eq(selected, custom), true, Bry_.new_u8(custom)); hash.Add(custom, itm); return (Xobc_xodir_dir[]) hash.To_ary(Xobc_xodir_dir.class); }
public void Init_by_wiki() { if (!init_needed) return; init_needed = false; if (String_.Eq(domain_str, "xowa")) return; // HACK: ignore "xowa" for now; WHEN:converting xowa to sqlitedb data_mgr__core_mgr = new Xow_db_mgr(this, fsys_mgr.Root_dir()); data_mgr__core_mgr.Init_by_load(gplx.xowa.wikis.data.Xow_db_file__core_.Find_core_fil(this)); app.Html__css_installer() .Install(this, Xowd_css_core_mgr.Key_mobile); // must init after data_mgr this.db_core_mgr = Fsdb_db_mgr_.new_detect(this, fsys_mgr.Root_dir(), fsys_mgr.File_dir()); if (db_core_mgr == null) // no fsdb; occurs during merge; also, will be null for xowa_db; DATE:2016-05-31 db_core_mgr = Fsdb_db_mgr__v2_bldr.Get_or_make(this, true); else // fsdb exists; load it fsdb_mgr.Mnt_mgr().Ctor_by_load(db_core_mgr); file_mgr__repo_mgr.Add_repo( app, fsys_mgr.File_dir(), Xow_domain_itm_.Bry__commons, Xow_domain_itm_.Bry__commons); file_mgr__repo_mgr.Add_repo(app, fsys_mgr.File_dir(), domain_bry, domain_bry); Xof_orig_tbl[] orig_tbls = db_core_mgr == null ? new Xof_orig_tbl[0] : db_core_mgr.File__orig_tbl_ary(); orig_mgr.Init_by_wiki(this, file_mgr__fsdb_mode, orig_tbls, Xof_url_bldr.new_v2()); fsdb_mgr.Init_by_wiki(this); data_mgr__core_mgr.Db__core().Tbl__ns().Select_all(ns_mgr); data_mgr__core_mgr.Db__core().Tbl__site_stats().Select(stats); html__hdump_mgr.Init_by_db(this); app.Addon_mgr().Load_by_wiki(this); ctg_pagebox_wtr.Init_by_wiki(this); }
public boolean Mustache__write(String key, Mustache_bfr bfr) { if (String_.Eq(key, "path")) bfr.Add_bry(path); else if (String_.Eq(key, "path_enc")) bfr.Add_bry(gplx.langs.htmls.encoders.Gfo_url_encoder_.Href.Encode(path)); else if (String_.Eq(key, "owner_dir_enc")) bfr.Add_bry(owner_dir_enc); else if (String_.Eq(key, "name")) bfr.Add_bry(name); else if (String_.Eq(key, "date")) bfr.Add_bry(date); else if (String_.Eq(key, "size")) bfr.Add_bry(size); else if (String_.Eq(key, "color")) bfr.Add_bry(color); else if (String_.Eq(key, "dir_cmd")) bfr.Add_bry(dir_cmd); else if (String_.Eq(key, "dir_cmd_arg")) { bfr.Add_str_u8("&dir_cmd="); bfr.Add_bry(dir_cmd); } else return false; return true; }
public static Fsdb_db_mgr new_src_bin_db_mgr(Xow_wiki wiki, String version) { String domain_str = wiki.Domain_str(); Fsdb_db_mgr rv = null; Io_url url = null; if (String_.Eq(version, "v1")) { url = wiki.Fsys_mgr() .File_dir() .OwnerDir() .GenSubDir(domain_str + "-prv"); // v1: EX: /xowa/file/en.wikipedia.org-prv/ rv = new Fsdb_db_mgr__v1(url); } else if (String_.Eq(version, "v2")) { url = wiki.Fsys_mgr().Root_dir().GenSubDir("prv"); // v2: EX: /xowa/wiki/en.wikipedia.org/prv/ rv = Fsdb_db_mgr_.new_detect(wiki, url, url); // note that v2 is prioritized over v1 } else throw Err_.new_wo_type("fsdb.make:unknown fsdb_type", "version", version); if (rv == null) throw Err_.new_wo_type( "fsdb.make:source fsdb not found", "version", version, "url", url.Raw()); return rv; }
public void Exec() { if (String_.Eq(text, "") && append) return; // no change; don't bother writing to disc IoEnginePool.Instance.Get_by(url.Info().EngineKey()).SaveFilText_api(this); }
public boolean Eq(IptArg comp) { return String_.Eq(key, comp.Key()); }
@Override public void Cmd_bgn(Xob_bldr bldr) { wiki.Init_assert(); this.poll_interval = poll_mgr.Poll_interval(); this.bin_db_mgr = new Xob_bin_db_mgr(ns_ids); // src_bin_mgr if (src_bin_mgr__fsdb_version != null) { this.src_fsdb_wkr = Xof_bin_wkr__fsdb_sql.new_(wiki.File__mnt_mgr()); src_bin_mgr.Wkrs__add(src_fsdb_wkr); src_fsdb_wkr.Mnt_mgr().Ctor_by_load(new_src_bin_db_mgr(wiki, src_bin_mgr__fsdb_version)); src_fsdb_wkr.Mnt_mgr() .Mnts__get_main() .Txn_bgn(); // NOTE: txn on atr speeds up from 50 -> 300; DATE:2015-03-21 if (src_bin_mgr__fsdb_skip_wkrs != null) { src_fsdb_wkr.Skip_mgr_init( src_fsdb_wkr.Mnt_mgr().Mnts__get_main().Cfg_mgr(), src_bin_mgr__fsdb_skip_wkrs); } if (src_bin_mgr__cache_enabled) { usr_dlg.Prog_many("", "", "src_bin_mgr.cache.bgn"); src_fsdb_wkr.Mnt_mgr().Mnts__get_main().Atr_mgr().Db__core().Fil_cache_enabled_y_(); usr_dlg.Prog_many("", "", "src_bin_mgr.cache.end"); } } if (src_bin_mgr__wmf_enabled) { Xof_bin_wkr__http_wmf wmf_wkr = Xof_bin_wkr__http_wmf.new_(wiki); src_bin_mgr.Wkrs__add(wmf_wkr); wmf_wkr.Fail_timeout_( 0); // 1000; NOTE: set Fail_timeout here; DATE:2014-06-21; NOTE: do not put in ctor, or // else will be 1st wkr; DATE:2014-06-28 } // trg_mnt_itm this.trg_bin_db_max = app.Api_root().Bldr().Wiki().Import().File_db_max(); Io_url trg_file_dir_v1 = String_.Eq(trg_bin_mgr__fsdb_version, "v1") ? wiki.Fsys_mgr().File_dir().GenNewNameOnly(wiki.Domain_str() + "-prv") : wiki.Fsys_mgr().File_dir(); // NOTE: convoluted way of setting trg to -prv if // trg_bin_mgr__fsdb_version_v1 is set; otherwise set to // "en.wikipedia.org" which will noop; DATE:2015-12-02 Fsdb_db_mgr trg_db_mgr = Fsdb_db_mgr_.new_detect(wiki, wiki.Fsys_mgr().Root_dir(), trg_file_dir_v1); if (trg_db_mgr == null) trg_db_mgr = Fsdb_db_mgr__v2_bldr.Get_or_make(wiki, Bool_.Y); Fsm_mnt_mgr trg_mnt_mgr = new Fsm_mnt_mgr(); trg_mnt_mgr.Ctor_by_load(trg_db_mgr); trg_mnt_mgr.Mnts__get_insert_idx_( Fsm_mnt_mgr .Mnt_idx_main); // NOTE: do not delete; mnt_mgr default to Mnt_idx_user; DATE:2014-04-25 this.trg_mnt_itm = trg_mnt_mgr.Mnts__get_insert(); Fsm_mnt_mgr.Patch( trg_mnt_itm.Cfg_mgr() .Tbl()); // NOTE: always patch again; fsdb_make may be run separately without lnki_temp; // DATE:2014-04-26 this.trg_atr_fil = trg_mnt_itm.Atr_mgr().Db__core(); this.trg_cfg_mgr = trg_mnt_itm.Cfg_mgr(); bin_db_mgr.Init_by_mnt_mgr(trg_mnt_mgr); trg_atr_fil.Conn().Txn_bgn("bldr__fsdb_make__trg_atr_fil"); if (!trg_atr_fil.Conn() .Eq(trg_cfg_mgr.Tbl().Conn())) // need to create txn for v1; DATE:2015-07-04 trg_cfg_mgr.Tbl().Conn().Txn_bgn("bldr__fsdb_make__trg_cfg_fil"); // bldr_db Xob_db_file bldr_db = Xob_db_file.New__file_make(wiki.Fsys_mgr().Root_dir()); this.bldr_conn = bldr_db.Conn(); this.bldr_cfg_tbl = bldr_db.Tbl__cfg(); // NOTE: cfg and atr is in same db; use it bldr_cfg_tbl.Conn().Txn_bgn("bldr__fsdb_make__bldr_cfg_tbl"); }