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