Exemplo n.º 1
0
 public static bool operator ==(BasePath path1, object path2)
 {
     if (BasePath.ReferenceEquals(path1, null))
     {
         return(BasePath.ReferenceEquals(path2, null));
     }
     return(path1.Equals(path2));
 }
Exemplo n.º 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);
 }
Exemplo n.º 3
0
 public static bool IsEmpty(BasePath basePath)
 {
     if (basePath == null)
     {
         throw new ArgumentNullException();
     }
     return(basePath.Path.Length == 0);
 }
Exemplo n.º 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));
 }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
 //
 //  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)));
 }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 14
0
 public static bool IsNullOrEmpty(BasePath basePath)
 {
     return basePath == null || IsEmpty(basePath);
 }
Exemplo n.º 15
0
 public static bool IsEmpty(BasePath basePath)
 {
     if (basePath == null) {
     throw new ArgumentNullException();
      }
      return basePath.Path.Length == 0;
 }
Exemplo n.º 16
0
 public static bool IsNullOrEmpty(BasePath basePath)
 {
     return(basePath == null || IsEmpty(basePath));
 }