mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Scribunto: Add 'dotted' form of file path [#353]
This commit is contained in:
parent
cd56234e28
commit
ebfd7a8352
@ -45,9 +45,19 @@ public class Scrib_fsys_mgr {
|
|||||||
Io_url fil = fils[i];
|
Io_url fil = fils[i];
|
||||||
if (!String_.Eq(fil.Ext(), ".lua")) continue; // ignore readme.txt, readme
|
if (!String_.Eq(fil.Ext(), ".lua")) continue; // ignore readme.txt, readme
|
||||||
gplx.core.ios.Io_fil fil_itm = new gplx.core.ios.Io_fil(fil, null);
|
gplx.core.ios.Io_fil fil_itm = new gplx.core.ios.Io_fil(fil, null);
|
||||||
rv.Add_if_dupe_use_1st(fil.NameOnly(), fil_itm);
|
// Scribunto allows multiple ways of lookup; for example, "a/b/c.lua"
|
||||||
rv.Add_if_dupe_use_1st(String_.Replace(String_.DelEndIf(fil.GenRelUrl_orEmpty(script_dir), ".lua"), "\\", "/"), fil_itm);
|
// * "c"
|
||||||
|
// * "a/b/c"
|
||||||
|
// * "a.b.c"
|
||||||
|
String rel_path = fil.GenRelUrl_orEmpty(script_dir); // get rel path; EX: "C:\xowa\a\b.lua" -> "a\b.lua"
|
||||||
|
if (gplx.core.envs.Op_sys.Cur().Tid_is_wnt()) // if windows, replace "\"
|
||||||
|
rel_path = String_.Replace(rel_path, fil.Info().DirSpr(), "/");
|
||||||
|
rel_path = String_.DelEndIf(rel_path, ".lua"); // remove ".lua"
|
||||||
|
rv.Add_if_dupe_use_1st(fil.NameOnly(), fil_itm); // add filename only (no extension); EX: "c"
|
||||||
|
rv.Add_if_dupe_use_1st(rel_path, fil_itm); // add relpath; EX: "a/b/c"
|
||||||
|
rv.Add_if_dupe_use_1st(String_.Replace(rel_path, "/", "."), fil_itm); // add relpath in dotted form; EX: "a.b.c"
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
public void Shrink() {
|
public void Shrink() {
|
||||||
|
@ -25,7 +25,9 @@ public class Scrib_fsys_mgr_tst {
|
|||||||
, "ustring/normalization-data.lua"
|
, "ustring/normalization-data.lua"
|
||||||
, "ustring/README"
|
, "ustring/README"
|
||||||
);
|
);
|
||||||
fxt.Test_exists_y("mw", "mw.ustring", "ustring", "ustring/normalization-data");
|
fxt.Test_exists_y("mw", "mw.ustring", "ustring", "normalization-data");
|
||||||
|
fxt.Test_exists_y("ustring/ustring", "ustring/normalization-data");
|
||||||
|
fxt.Test_exists_y("ustring.ustring", "ustring.normalization-data");
|
||||||
fxt.Test_exists_n("README");
|
fxt.Test_exists_n("README");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user