Beispiel #1
0
  private static IoItmFil Get_itm_by_filters(Io_url dir, String... filter_ary) {
    // create array of matches based on filters
    int match_ary_len = filter_ary.length;
    Criteria_ioMatch[] match_ary = new Criteria_ioMatch[match_ary_len];
    for (int i = 0; i < match_ary_len; ++i)
      match_ary[i] = Criteria_ioMatch.parse_(true, filter_ary[i], dir.Info().CaseSensitive());

    // get files and check each file for match
    IoItmFil rv = null;
    IoItmHash itm_hash = Io_mgr.I.QueryDir_args(dir).ExecAsItmHash();
    int len = itm_hash.Count();
    for (int i = 0; i < len; ++i) {
      IoItm_base itm = itm_hash.Get_at(i);
      for (int j = 0; j < match_ary_len; ++j) {
        if (itm.Type_fil() && match_ary[j].Matches(itm.Url()))
          rv =
              (IoItmFil)
                  itm; // NOTE: this will return the last match; useful for getting latest dump when
                       // multiple dumps are in one dir; (assuming latest should alphabetize last)
      }
    }
    return rv;
  }
 private static void New_subs(Io_url owner_dir, List_adp list, IoItmList subs, byte[] dir_cmd) {
   subs.Sort();
   int len = subs.Len();
   int list_total = list.Len();
   byte[] owner_dir_bry = owner_dir.RawBry();
   for (int i = 0; i < len; ++i) {
     IoItm_base src = (IoItm_base) subs.Get_at(i);
     Xow_import_doc trg = null;
     if (src.Type_dir()) {
       byte[] trg_url = src.Url().RawBry();
       trg =
           new Xow_import_doc(
               Bool_.Y,
               Bool_.N,
               list_total + i,
               owner_dir_bry,
               trg_url,
               Bry_.new_u8(src.Url().NameAndExt_noDirSpr()),
               Bry_.Empty,
               Bry_.Empty,
               dir_cmd,
               Ary_empty);
     } else {
       IoItmFil src_as_fil = (IoItmFil) src;
       String size_str = Io_size_.To_str(src_as_fil.Size(), "#,###");
       boolean is_xowa_core =
           gplx.xowa.wikis.data.Xow_db_file__core_.Is_core_fil_name(
               owner_dir.NameOnly(), src.Url().NameAndExt());
       trg =
           new Xow_import_doc(
               Bool_.N,
               is_xowa_core,
               list_total + i,
               owner_dir_bry,
               src.Url().RawBry(),
               Bry_.new_u8(src.Name()),
               Bry_.new_u8(src_as_fil.ModifiedTime().XtoStr_fmt("yyyy-MM-dd")),
               Bry_.new_u8(size_str),
               dir_cmd,
               Ary_empty);
     }
     list.Add(trg);
   }
 }