public override void Guide(URLHandler.URLVisitor v, bool recurse, bool strip) { /*if (System.IO.Directory.Exists(file.DirectoryName)) { * Process(v, recurse, strip, "/", file.ListFiles()); * } else { * v.Visit(file.Name); * }*/ }
public void Process(URLHandler.URLVisitor v, bool recurse, bool strip, String path, FileInfo[] files) { /*for (int i = 0; i < files.Length; i++) { * FileInfo f = files[i]; * * if (System.IO.Directory.Exists(f.DirectoryName)) { * if (recurse) { * Process(v, recurse, strip, path + f.Name + '/', * f.ListFiles()); * } * } else { * v.Visit((strip) ? f.Name : path + f.Name); * } * }*/ }
public abstract void Guide(URLHandler.URLVisitor visitor, bool recurse, bool strip);
/*private class JarURLHandler : URLHandler { * internal JarFile jarFile; * * internal String prefix; * * internal JarURLHandler(Uri url) { * try { * prefix = url.GetPath(); * * int ix = prefix.IndexOf("!/"); * * if (ix >= 0) { * prefix = prefix.Substring(ix + 2); // truncate after "!/" * } * * JarURLConnection conn = (JarURLConnection) WebRequest.Create(url); * * jarFile = conn.GetJarFile(); * } catch (Exception e) { * if (IBM.ICU.Impl.URLHandler.DEBUG) * System.Console.Error.WriteLine("icurb jar error: " + e); * throw new ArgumentException("jar error: " + e.Message); + } + } + + public override void Guide(URLHandler.URLVisitor v, bool recurse, bool strip) { + try { + IIterator entries = jarFile.Entries(); + + while (entries.HasNext()) { + JarEntry entry = (JarEntry) entries.Next(); + + if (!entry.IsDirectory()) { // skip just directory paths + String name = entry.GetName(); + + if (name.StartsWith(prefix)) { + name = name.Substring(prefix.Length); + + int ix = name.LastIndexOf('/'); + + if (ix != -1) { + if (!recurse) { + continue; + } + + if (strip) { + name = name.Substring(ix + 1); + } + } + + v.Visit(name); + } + } + } + } catch (Exception e) { + if (IBM.ICU.Impl.URLHandler.DEBUG) + System.Console.Error.WriteLine("icurb jar error: " + e); + } + } + }*/ public void Guide(URLHandler.URLVisitor visitor, bool recurse) { Guide(visitor, recurse, true); }