/// <summary> /// Return a map to use for Pod.files() /// </summary> public List podFiles(Fan.Sys.Uri podUri) { List list = new List(Sys.FileType); IEnumerator en = zipFile.GetEnumerator(); while (en.MoveNext()) { ZipEntry entry = (ZipEntry)en.Current; string name = entry.Name; if (name.EndsWith(".fcode")) { continue; } if (name.EndsWith(".class")) { continue; } if (name.EndsWith(".def") && !name.Contains("/")) { continue; } Fan.Sys.Uri uri = Fan.Sys.Uri.fromStr(podUri + "/" + LocalFile.fileNameToUriName(entry.Name)); Fan.Sys.ZipEntryFile file = new Fan.Sys.ZipEntryFile(zipFile, entry, uri); list.add(file); } return(list); }
public Map get(Pod pod, Uri uri, Duration maxAge) { Key key = new Key(pod, uri); CachedProps cp = (CachedProps)m_cache[key]; if (cp == null || Duration.nowTicks() - cp.m_read > maxAge.m_ticks) cp = refresh(key, cp); return cp.m_props; }
public override FTable read(FStore.Input input) { if (input == null) { m_size = 0; return(this); } m_size = input.u2(); m_table = new object[m_size]; for (int i = 0; i < m_size; i++) { m_table[i] = Uri.fromStr(input.utf()); } return(this); }
public LocalFile(Uri uri, FileSystemInfo file) : base(uri) { this.m_file = file; if (System.IO.Directory.Exists(file.FullName)) { if (!uri.isDir()) throw IOErr.make("Must use trailing slash for dir: " + uri).val; } else if (System.IO.File.Exists(file.FullName)) { if (uri.isDir()) throw IOErr.make("Cannot use trailing slash for file: " + uri).val; } }
static Map readDef(Pod pod, Uri uri) { uri = Uri.fromStr(pod.uri() + "/" + uri); Fan.Sys.File f = (Fan.Sys.File)pod.file(uri, false); Map map = Sys.m_emptyStrStrMap; try { if (f != null) map = (Map)f.readProps().toImmutable(); } catch (System.Exception e) { System.Console.WriteLine("ERROR: Cannot load props " + pod + "::" + uri); System.Console.WriteLine(" " + e); } return map; }
public override File plus(Uri uri, bool checkSlash) { return make(m_uri.plus(uri), checkSlash); }
public static string uriToPath(Uri uri) { string path = uri.m_pathStr; bool dir = uri.isDir(); int len = path.Length; StringBuilder s = new StringBuilder(path.Length); for (int i=0; i<len; ++i) { int c = path[i]; if (i == 0 && c == '/' && path.Contains(":")) continue; // skip abs if (i == len-1 && c == '/' && dir) continue; // skip trailing slash switch (c) { case '\\': break; case '/': s.Append('\\'); break; default: s.Append((char)c); break; } } return s.ToString(); }
public static FileSystemInfo uriToFile(Uri uri) { if (uri.scheme() != null && uri.scheme() != "file") throw ArgErr.make("Invalid Uri scheme for local file: " + uri).val; string path = uriToPath(uri); if (System.IO.Directory.Exists(path)) return new DirectoryInfo(path); if (System.IO.File.Exists(path)) return new FileInfo(path); if (uri.isDir()) return new DirectoryInfo(path); return new FileInfo(path); }
public override File plus(Uri uri, bool checkSlash) { // TODO throw UnsupportedErr.make("ZipEntryFile.plus").val; }
public virtual Map props(Pod pod, Uri uri, Duration maxAge) { return m_props.get(pod, uri, maxAge); }
public virtual File findFile(Uri uri, bool check) { return m_parent.findFile(uri, check); }
public virtual File findFile(Uri uri) { return findFile(uri, true); }
public virtual List findAllFiles(Uri uri) { return m_parent.findAllFiles(uri); }
public abstract object get(Uri uri, object @base);
public LocalFile(Uri uri) : this(uri, uriToFile(uri)) { }
public OutStream writeNext(Uri path) { return writeNext(path, DateTime.now()); }
public OutStream writeNext(Uri path, DateTime modifyTime) { if (m_zipOut == null) throw UnsupportedErr.make("Zip not opened for writing").val; if (path.frag() != null) throw ArgErr.make("Path must not contain fragment: " + path).val; if (path.queryStr() != null) throw ArgErr.make("Path must not contain query: " + path).val; try { string zipPath = path.ToString(); if (zipPath.StartsWith("/")) zipPath = zipPath.Substring(1); ZipEntry entry = new ZipEntry(zipPath); entry.DateTime = new System.DateTime(modifyTime.dotnet()); m_zipOut.PutNextEntry(entry); return new ZipSysOutStream(m_zipOut); } catch (System.IO.IOException e) { throw IOErr.make(e).val; } }
////////////////////////////////////////////////////////////////////////// // Construction ////////////////////////////////////////////////////////////////////////// public ZipEntryFile(ZipFile parent, ZipEntry entry, Uri uri) : base(uri) { this.m_parent = parent; this.m_entry = entry; }
public Key(Pod p, Uri u) { m_pod = p; m_uri = u; }