Uri is used to immutably represent a Universal Resource Identifier.
Inheritance: FanObj, Literal
Exemple #1
0
        /// <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);
        }
Exemple #2
0
 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;
 }
Exemple #3
0
 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);
 }
Exemple #4
0
 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;
       }
 }
Exemple #5
0
 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;
 }
Exemple #6
0
 public override File plus(Uri uri, bool checkSlash)
 {
     return make(m_uri.plus(uri), checkSlash);
 }
Exemple #7
0
 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();
 }
Exemple #8
0
 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);
 }
Exemple #9
0
 public override File plus(Uri uri, bool checkSlash)
 {
     // TODO
       throw UnsupportedErr.make("ZipEntryFile.plus").val;
 }
Exemple #10
0
 public virtual Map props(Pod pod, Uri uri, Duration maxAge)
 {
     return m_props.get(pod, uri, maxAge);
 }
Exemple #11
0
 public virtual File findFile(Uri uri, bool check)
 {
     return m_parent.findFile(uri, check);
 }
Exemple #12
0
 public virtual File findFile(Uri uri)
 {
     return findFile(uri, true);
 }
Exemple #13
0
 public virtual List findAllFiles(Uri uri)
 {
     return m_parent.findAllFiles(uri);
 }
Exemple #14
0
 public abstract object get(Uri uri, object @base);
Exemple #15
0
 public LocalFile(Uri uri)
     : this(uri, uriToFile(uri))
 {
 }
Exemple #16
0
 public OutStream writeNext(Uri path)
 {
     return writeNext(path, DateTime.now());
 }
Exemple #17
0
 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;
       }
 }
Exemple #18
0
 //////////////////////////////////////////////////////////////////////////
 // Construction
 //////////////////////////////////////////////////////////////////////////
 public ZipEntryFile(ZipFile parent, ZipEntry entry, Uri uri)
     : base(uri)
 {
     this.m_parent = parent;
       this.m_entry  = entry;
 }
Exemple #19
0
 public Key(Pod p, Uri u)
 {
     m_pod = p; m_uri = u;
 }