isPathAbs() public method

public isPathAbs ( ) : bool
return bool
コード例 #1
0
ファイル: BootEnv.cs プロジェクト: nomit007/f4
 //////////////////////////////////////////////////////////////////////////
 // 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;
 }
コード例 #2
0
ファイル: Uri.cs プロジェクト: xored/f4
        //////////////////////////////////////////////////////////////////////////
        // Plus
        //////////////////////////////////////////////////////////////////////////
        public Uri plus(Uri r)
        {
            // if r is more or equal as absolute as base, return r
              if (r.m_scheme != null) return r;
              if (r.m_host != null && this.m_scheme == null) return r;
              if (r.isPathAbs() && this.m_host == null) return r;

              // this algorthm is lifted straight from
              // RFC 3986 (5.2.2) Transform References;
              Uri baseUri = this;
              Sections t = new Sections();
              if (r.m_host != null)
              {
            t.setAuth(r);
            t.setPath(r);
            t.setQuery(r);
              }
              else
              {
            if (r.m_pathStr == null || r.m_pathStr == "")
            {
              t.setPath(baseUri);
              if (r.m_queryStr != null)
            t.setQuery(r);
              else
            t.setQuery(baseUri);
            }
            else
            {
              if (r.m_pathStr.StartsWith("/"))
            t.setPath(r);
              else
            merge(t, baseUri, r);
              t.setQuery(r);
            }
            t.setAuth(baseUri);
              }
              t.scheme = baseUri.m_scheme;
              t.frag   = r.m_frag;
              t.normalize();
              return new Uri(t);
        }
コード例 #3
0
ファイル: Uri.cs プロジェクト: xored/f4
        static void merge(Sections t, Uri baseUri, Uri r)
        {
            bool baseIsAbs = baseUri.isPathAbs();
              bool baseIsDir = baseUri.isDir();
              bool rIsDir    = r.isDir();
              List rPath     = r.m_path;
              bool dotLast   = false;

              // compute the target path taking into account whether
              // the base is a dir and any dot segments in relative ref
              List tPath;
              if (baseUri.m_path.sz() == 0)
              {
            tPath = r.m_path;
              }
              else
              {
            tPath = baseUri.m_path.rw();
            if (!baseIsDir) tPath.pop();
            for (int i=0; i<rPath.sz(); ++i)
            {
              string rSeg = (string)rPath.get(i);
              if (rSeg == ".") { dotLast = true; continue; }
              if (rSeg == "..")
              {
            if (!tPath.isEmpty()) { tPath.pop(); dotLast = true; continue; }
            if (baseIsAbs) continue;
              }
              tPath.add(rSeg); dotLast = false;
            }
            //tPath = tPath;
              }

              t.path = tPath;
              t.pathStr = toPathStr(baseIsAbs, tPath, rIsDir || dotLast);
        }
コード例 #4
0
ファイル: Pod.cs プロジェクト: nomit007/f4
 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;
 }