make() public static method

public static make ( ) : UnresolvedErr
return UnresolvedErr
Example #1
0
        public static UriScheme find(string scheme, bool check)
        {
            // check cache
            lock (m_cache)
            {
                UriScheme cached = (UriScheme)m_cache[scheme];
                if (cached != null)
                {
                    return(cached);
                }
            }

            try
            {
                // lookup scheme type (avoid building index for common types)
                Type t = null;
                if (scheme == "fan")
                {
                    t = Sys.FanSchemeType;
                }
                if (scheme == "file")
                {
                    t = Sys.FileSchemeType;
                }
                if (t == null)
                {
                    string qname = (string)Env.cur().index("sys.uriScheme." + scheme).first();
                    if (qname == null)
                    {
                        throw UnresolvedErr.make().val;
                    }
                    t = Type.find(qname);
                }

                // allocate instance
                UriScheme s = (UriScheme)t.make();
                s.m_scheme = scheme;

                // add to cache
                lock (m_cache)
                {
                    UriScheme cached = (UriScheme)m_cache[scheme];
                    if (cached != null)
                    {
                        return(cached);
                    }
                    m_cache[scheme] = s;
                }

                return(s);
            }
            catch (UnresolvedErr.Val) {}
            catch (System.Exception e) { Err.dumpStack(e); }

            if (!check)
            {
                return(null);
            }
            throw UnresolvedErr.make("Unknown scheme: " + scheme).val;
        }
Example #2
0
        //////////////////////////////////////////////////////////////////////////
        // Find Files
        //////////////////////////////////////////////////////////////////////////

        public override File findFile(Uri uri, bool check)
        {
            if (uri.isPathAbs())
            {
                throw ArgErr.make("Uri must be relative: " + uri).val;
            }
            File f = m_homeDir.plus(uri, false);

            if (f.exists())
            {
                return(f);
            }
            if (!check)
            {
                return(null);
            }
            throw UnresolvedErr.make("File not found in Env: " + uri).val;
        }
Example #3
0
 public Fan.Sys.File file(Uri uri, bool check)
 {
     loadFiles();
     if (!uri.isPathAbs())
     {
         throw ArgErr.make("Pod.files Uri must be path abs: " + uri).val;
     }
     if (uri.auth() != null && !uri.toStr().StartsWith(this.uri().toStr()))
     {
         throw ArgErr.make("Invalid base uri `" + uri + "` for `" + this.uri() + "`").val;
     }
     else
     {
         uri = this.uri().plus(uri);
     }
     Fan.Sys.File f = (Fan.Sys.File)m_filesMap[uri];
     if (f != null || !check)
     {
         return(f);
     }
     throw UnresolvedErr.make(uri.toStr()).val;
 }