示例#1
0
 public static bool operator ==(BasePath path1, object path2)
 {
     if (BasePath.ReferenceEquals(path1, null))
     {
         return(BasePath.ReferenceEquals(path2, null));
     }
     return(path1.Equals(path2));
 }
示例#2
0
 public static bool DoesPathHasThisPathMode(BasePath basePath, PathMode pathMode)
 {
     if (basePath == null) {
     throw new ArgumentNullException();
      }
      return (basePath.IsAbsolutePath && pathMode == PathMode.Absolute) ||
         (basePath.IsRelativePath && pathMode == PathMode.Relative);
 }
示例#3
0
 public static bool IsEmpty(BasePath basePath)
 {
     if (basePath == null)
     {
         throw new ArgumentNullException();
     }
     return(basePath.Path.Length == 0);
 }
示例#4
0
 public static bool DoesPathHasThisPathMode(BasePath basePath, PathMode pathMode)
 {
     if (basePath == null)
     {
         throw new ArgumentNullException();
     }
     return((basePath.IsAbsolutePath && pathMode == PathMode.Absolute) ||
            (basePath.IsRelativePath && pathMode == PathMode.Relative));
 }
示例#5
0
        public override bool Equals(object obj)
        {
            BasePath basePath = obj as BasePath;

            if (!BasePath.ReferenceEquals(basePath, null))
            {
                // Comparaison du contenu.
                return(this.Equals(basePath));
            }
            return(false);
        }
 //
 //  Absolute/Relative path conversion
 //
 public DirectoryPathAbsolute GetAbsolutePathFrom(DirectoryPathAbsolute path)
 {
     if (path == null)
     {
         throw new ArgumentNullException();
     }
     if (PathHelper.IsEmpty(this) || PathHelper.IsEmpty(path))
     {
         throw new ArgumentException("Cannot compute an absolute path from an empty path.");
     }
     return(new DirectoryPathAbsolute(BasePath.GetAbsolutePathFrom(path, this)));
 }
示例#7
0
        //
        //  Absolute/Relative path conversion
        //
        public FilePathAbsolute GetAbsolutePathFrom(DirectoryPathAbsolute path)
        {
            if (path == null)
            {
                throw new ArgumentNullException();
            }
            if (PathHelper.IsEmpty(this) || PathHelper.IsEmpty(path))
            {
                throw new ArgumentException("Cannot compute an absolute path from an empty path.");
            }
            string pathAbsolute = BasePath.GetAbsolutePathFrom(path, this);

            return(new FilePathAbsolute(pathAbsolute + System.IO.Path.DirectorySeparatorChar + this.FileName));
        }
示例#8
0
        protected static string GetAbsolutePathFrom(DirectoryPathAbsolute pathFrom, BasePath pathTo)
        {
            Debug.Assert(pathTo.IsRelativePath);
            // %HYYKA%

            /*if (pathTo.PathMode == PathMode.Absolute) {
             * throw new ArgumentException(@"Cannot call GetAbsolutePath() on a path already absolute.
             * PathFrom = """ + pathFrom.Path + @"""
             * PathTo   = """ + pathTo.Path + @"""");
             * }*/
            // Only work with Directory
            if (pathTo.IsFilePath)
            {
                pathTo = pathTo.ParentDirectoryPath;
            }
            return(InternalStringHelper.GetAbsolutePath(pathFrom.Path, pathTo.Path));
        }
示例#9
0
        //
        // Comparison
        //
        private bool Equals(BasePath path)
        {
            Debug.Assert(path != null);

            if (path.IsEmpty)
            {
                return(this.IsEmpty);
            }

            if (this.IsAbsolutePath != path.IsAbsolutePath)
            {
                return(false);
            }
            // A FilePath could be equal to a DirectoryPath
            if (this.IsDirectoryPath != path.IsDirectoryPath)
            {
                return(false);
            }
            return(string.Compare(this.m_Path, path.m_Path, true) == 0);
        }
示例#10
0
        //
        //  Relative/absolute
        //
        protected static string GetPathRelative(DirectoryPathAbsolute pathFrom, BasePath pathTo)
        {
            Debug.Assert(pathTo.IsAbsolutePath);
            // %HYYKA%

            /*if (pathTo.PathMode == PathMode.Relative) {
             * throw new ArgumentException(@"Cannot input a relative path to GetPathRelativeTo().
             * PathFrom = """ + pathFrom.Path + @"""
             * PathTo   = """ + pathTo.Path + @"""");
             * }*/
            if (string.Compare(pathFrom.DriveProtected, pathTo.DriveProtected, true) != 0)
            {
                throw new ArgumentException(@"Cannot compute relative path from 2 paths that are not on the same drive 
PathFrom = """ + pathFrom.Path + @"""
PathTo   = """ + pathTo.Path + @"""");
            }
            // Only work with Directory
            if (pathTo.IsFilePath)
            {
                pathTo = pathTo.ParentDirectoryPath;
            }
            return(InternalStringHelper.GetPathRelativeTo(pathFrom.Path, pathTo.Path));
        }
示例#11
0
        //
        // Comparison
        //
        private bool Equals(BasePath path)
        {
            Debug.Assert(path != null);

             if (path.IsEmpty) {
            return this.IsEmpty;
             }

             if (this.IsAbsolutePath != path.IsAbsolutePath) {
            return false;
             }
             // A FilePath could be equal to a DirectoryPath
             if (this.IsDirectoryPath != path.IsDirectoryPath) {
            return false;
             }
             return string.Compare(this.m_Path, path.m_Path, true) == 0;
        }
示例#12
0
 //
 //  Relative/absolute
 //
 protected static string GetPathRelative(DirectoryPathAbsolute pathFrom, BasePath pathTo)
 {
     Debug.Assert(pathTo.IsAbsolutePath);
      // %HYYKA%
      /*if (pathTo.PathMode == PathMode.Relative) {
     throw new ArgumentException(@"Cannot input a relative path to GetPathRelativeTo().
     PathFrom = """ + pathFrom.Path + @"""
     PathTo   = """ + pathTo.Path + @"""");
      }*/
      if (string.Compare(pathFrom.DriveProtected, pathTo.DriveProtected, true) != 0) {
     throw new ArgumentException(@"Cannot compute relative path from 2 paths that are not on the same drive
     PathFrom = """ + pathFrom.Path + @"""
     PathTo   = """ + pathTo.Path + @"""");
      }
      // Only work with Directory
      if (pathTo.IsFilePath) { pathTo = pathTo.ParentDirectoryPath; }
      return InternalStringHelper.GetPathRelativeTo(pathFrom.Path, pathTo.Path);
 }
示例#13
0
 protected static string GetAbsolutePathFrom(DirectoryPathAbsolute pathFrom, BasePath pathTo)
 {
     Debug.Assert(pathTo.IsRelativePath);
      // %HYYKA%
      /*if (pathTo.PathMode == PathMode.Absolute) {
     throw new ArgumentException(@"Cannot call GetAbsolutePath() on a path already absolute.
     PathFrom = """ + pathFrom.Path + @"""
     PathTo   = """ + pathTo.Path + @"""");
      }*/
      // Only work with Directory
      if (pathTo.IsFilePath) { pathTo = pathTo.ParentDirectoryPath; }
      return InternalStringHelper.GetAbsolutePath(pathFrom.Path, pathTo.Path);
 }
示例#14
0
 public static bool IsNullOrEmpty(BasePath basePath)
 {
     return basePath == null || IsEmpty(basePath);
 }
示例#15
0
 public static bool IsEmpty(BasePath basePath)
 {
     if (basePath == null) {
     throw new ArgumentNullException();
      }
      return basePath.Path.Length == 0;
 }
示例#16
0
 public static bool IsNullOrEmpty(BasePath basePath)
 {
     return(basePath == null || IsEmpty(basePath));
 }