1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Source: Restore broken commit

This commit is contained in:
gnosygnu
2017-02-06 22:14:55 -05:00
parent 938beac9f9
commit 3bfeb94b43
4380 changed files with 328018 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
/*
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.bldrs.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.ios.*;
import gplx.xowa.wikis.nss.*;
public class Xob_tmp_wtr {
Xob_tmp_wtr(Xow_ns ns_itm, Io_url_gen url_gen, int fil_max) {
this.ns_itm = ns_itm;
this.url_gen = url_gen;
this.fil_max = fil_max;
bfr = Bry_bfr_.Reset(fil_max);
} int fil_max;
public Bry_bfr Bfr() {return bfr;} Bry_bfr bfr;
public Io_url_gen Url_gen() {return url_gen;} Io_url_gen url_gen;
public void Clear() {bfr.ClearAndReset();}
public boolean FlushNeeded(int writeLen) {return bfr.Len() + writeLen > fil_max;} //int bfr_len;
public Xow_ns Ns_itm() {return ns_itm;} private Xow_ns ns_itm;
public void Flush(Gfo_usr_dlg usr_dlg) {
if (bfr.Len() == 0) return; // nothing to flush
Io_url url = url_gen.Nxt_url();
Io_mgr.Instance.AppendFilBfr(url, bfr);
}
public void Rls() {bfr.Rls();}
public static Xob_tmp_wtr new_(Xow_ns ns_itm, Io_url_gen url_gen, int fil_max) {return new Xob_tmp_wtr(ns_itm, url_gen, fil_max);}
public static Xob_tmp_wtr new_wo_ns_(Io_url_gen url_gen, int fil_max) {return new Xob_tmp_wtr(null, url_gen, fil_max);}
}

View File

@@ -0,0 +1,45 @@
/*
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.bldrs.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.xowa.wikis.nss.*;
public class Xob_tmp_wtr_mgr {
public Xob_tmp_wtr[] Regy() {return regy;} private Xob_tmp_wtr[] regy = new Xob_tmp_wtr[Ns_ordinal_max];
public Xob_tmp_wtr_mgr(Xob_tmp_wtr_wkr wkr) {this.wkr = wkr;} private Xob_tmp_wtr_wkr wkr;
public Xob_tmp_wtr Get_or_new(Xow_ns ns) {
Xob_tmp_wtr rv = regy[ns.Ord()];
if (rv == null) {
rv = wkr.Tmp_wtr_new(ns);
regy[ns.Ord()] = rv;
}
return rv;
}
public void Flush_all(Gfo_usr_dlg usr_dlg) {
for (int i = 0; i < Ns_ordinal_max; i++) {
Xob_tmp_wtr wtr = regy[i];
if (wtr != null) {
wtr.Flush(usr_dlg);
wtr.Rls();
}
}
}
public void Rls_all() {
for (int i = 0; i < Ns_ordinal_max; i++)
regy[i] = null;
}
static final int Ns_ordinal_max = Xow_ns_mgr_.Ordinal_max; // ASSUME: no more than 128 ns in a wiki
}

View File

@@ -0,0 +1,23 @@
/*
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.bldrs.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.ios.*;
import gplx.xowa.wikis.nss.*;
public interface Xob_tmp_wtr_wkr {
Xob_tmp_wtr Tmp_wtr_new(Xow_ns ns);
}

View File

@@ -0,0 +1,26 @@
/*
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.bldrs.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.ios.*;
import gplx.xowa.wikis.nss.*;
public class Xob_tmp_wtr_wkr__ttl implements Xob_tmp_wtr_wkr {
public Xob_tmp_wtr_wkr__ttl(Io_url temp_dir, int dump_fil_len) {this.temp_dir = temp_dir; this.dump_fil_len = dump_fil_len;} Io_url temp_dir; int dump_fil_len;
public Xob_tmp_wtr Tmp_wtr_new(Xow_ns ns) {
return Xob_tmp_wtr.new_(ns, Io_url_gen_.dir_(temp_dir.GenSubDir_nest(ns.Num_str(), "dump")), dump_fil_len);
}
}