Exemple #1
0
 public static bool IsEmpty(BasePath basePath)
 {
     if (basePath == null)
     {
         throw new ArgumentNullException();
     }
     return(basePath.Path.Length == 0);
 }
Exemple #2
0
        public static bool operator ==(BasePath path1, object path2)
        {
            if (BasePath.ReferenceEquals(path1, null))
            {
                return(BasePath.ReferenceEquals(path2, null));
            }

            return(path1.Equals(path2));
        }
Exemple #3
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));
 }
Exemple #4
0
        protected static string GetAbsolutePathFrom(DirectoryPathAbsolute pathFrom, BasePath pathTo)
        {
            Debug.Assert(pathTo.IsRelativePath);

            if (pathTo.IsFilePath)
            {
                pathTo = pathTo.ParentDirectoryPath;
            }

            return(InternalStringHelper.GetAbsolutePath(pathFrom.Path, pathTo.Path));
        }
Exemple #5
0
        public override bool Equals(object obj)
        {
            BasePath basePath = obj as BasePath;

            if (!BasePath.ReferenceEquals(basePath, null))
            {
                return(this.Equals(basePath));
            }

            return(false);
        }
 //
 //  Absolute/Relative path conversion
 //
 public DirectoryPathRelative GetPathRelativeFrom(DirectoryPathAbsolute path)
 {
     if (path == null)
     {
         throw new ArgumentNullException();
     }
     if (PathHelper.IsEmpty(this) || PathHelper.IsEmpty(path))
     {
         throw new ArgumentException("Cannot compute a relative path from an empty path.");
     }
     return(new DirectoryPathRelative(BasePath.GetPathRelative(path, this)));
 }
Exemple #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));
        }
Exemple #8
0
        protected static string GetPathRelative(DirectoryPathAbsolute pathFrom, BasePath pathTo)
        {
            Debug.Assert(pathTo.IsAbsolutePath);

            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 + @"""");
            }

            if (pathTo.IsFilePath)
            {
                pathTo = pathTo.ParentDirectoryPath;
            }

            return(InternalStringHelper.GetPathRelativeTo(pathFrom.Path, pathTo.Path));
        }
Exemple #9
0
        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);
        }
Exemple #10
0
 public static bool IsNullOrEmpty(BasePath basePath)
 {
     return(basePath == null || IsEmpty(basePath));
 }