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