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