public bool CanGetAbsolutePathFrom(IAbsoluteDirectoryPath path, out string failureMessage) { Debug.Assert(path != null); // Enforced by contract string pathAbsoluteUnused; return(AbsoluteRelativePathHelpers.TryGetAbsolutePathFrom(path, this, out pathAbsoluteUnused, out failureMessage)); }
public override bool CanGetRelativePathFrom(IAbsoluteDirectoryPath pivotDirectory, out string failureReason) { Debug.Assert(pivotDirectory != null); // Enforced by contract string pathResultUnused; return(AbsoluteRelativePathHelpers.TryGetRelativePath(pivotDirectory, this, out pathResultUnused, out failureReason)); }
public override bool CanGetRelativePathFrom(IAbsoluteDirectoryPath pivotDirectory, out string failureMessage) { Argument.IsNotNull(nameof(pivotDirectory), pivotDirectory); string pathResultUnused; return(AbsoluteRelativePathHelpers.TryGetRelativePath(pivotDirectory, this, out pathResultUnused, out failureMessage)); }
public bool CanGetAbsolutePathFrom(IAbsoluteDirectoryPath path, out string failureMessage) { Argument.IsNotNull(nameof(path), path); string absolutePath; return(AbsoluteRelativePathHelpers.TryGetAbsolutePathFrom(path, this, out absolutePath, out failureMessage)); }
protected PathBase(string path) { Argument.IsNotNullOrEmpty(nameof(path), path); // At this point we know pathString is a valid path // but we need to normalize and resolve inner dir of path string var pathStringNormalized = AbsoluteRelativePathHelpers.NormalizeAndResolveInnerSpecialDir(path); CurrentPath = pathStringNormalized; }
// // Ctor // protected PathBase(string pathString) { Debug.Assert(pathString != null); Debug.Assert(pathString.Length > 0); // At this point we know pathString is a valid path // but we need to normalize and resolve inner dir of path string var pathStringNormalized = AbsoluteRelativePathHelpers.NormalizeAndResolveInnerSpecialDir(pathString); m_PathString = pathStringNormalized; }
// // Absolute/Relative pathString conversion // IAbsoluteDirectoryPath IRelativeDirectoryPath.GetAbsolutePathFrom(IAbsoluteDirectoryPath path) { Debug.Assert(path != null); // Enforced by contracts! string pathAbsolute, failureReason; if (!AbsoluteRelativePathHelpers.TryGetAbsolutePathFrom(path, this, out pathAbsolute, out failureReason)) { throw new ArgumentException(failureReason); } Debug.Assert(pathAbsolute != null); Debug.Assert(pathAbsolute.Length > 0); return(pathAbsolute.ToAbsoluteDirectoryPath()); }
// // Absolute/Relative pathString conversion // IRelativeDirectoryPath IAbsoluteDirectoryPath.GetRelativePathFrom(IAbsoluteDirectoryPath pivotDirectory) { Debug.Assert(pivotDirectory != null); string pathRelativeString, failureReason; if (!AbsoluteRelativePathHelpers.TryGetRelativePath(pivotDirectory, this, out pathRelativeString, out failureReason)) { throw new ArgumentException(failureReason); } Debug.Assert(pathRelativeString != null); Debug.Assert(pathRelativeString.Length > 0); return(pathRelativeString.ToRelativeDirectoryPath()); }
// // Absolute/Relative pathString conversion // IRelativeFilePath IAbsoluteFilePath.GetRelativePathFrom(IAbsoluteDirectoryPath pivotDirectory) { Debug.Assert(pivotDirectory != null); // Enforced by contract string pathRelative, failureReason; if (!AbsoluteRelativePathHelpers.TryGetRelativePath(pivotDirectory, this, out pathRelative, out failureReason)) { throw new ArgumentException(failureReason); } Debug.Assert(pathRelative != null); Debug.Assert(pathRelative.Length > 0); return(new RelativeFilePath(pathRelative + MiscHelpers.DIR_SEPARATOR_CHAR + FileName)); }
protected AbsolutePathBase(string pathString) : base(pathString) { Debug.Assert(pathString != null); Debug.Assert(pathString.Length > 0); if (UNCPathHelper.IsAnAbsoluteUNCPath(m_PathString)) { Kind = AbsolutePathKind.UNC; } else { Debug.Assert(AbsoluteRelativePathHelpers.IsAnAbsoluteDriveLetterPath(m_PathString)); Kind = AbsolutePathKind.DriveLetter; } }
IAbsoluteFilePath IRelativeFilePath.GetAbsolutePathFrom(IAbsoluteDirectoryPath path) { Argument.IsNotNull(nameof(path), path); string absolutePath, failureMessage; if (!AbsoluteRelativePathHelpers.TryGetAbsolutePathFrom(path, this, out absolutePath, out failureMessage)) { throw new ArgumentException(failureMessage); } //Debug.Assert(pathAbsolute != null); //Debug.Assert(pathAbsolute.Length > 0); return((absolutePath + MiscHelpers.DirectorySeparatorChar + FileName).ToAbsoluteFilePath()); }
IRelativeFilePath IAbsoluteFilePath.GetRelativePathFrom(IAbsoluteDirectoryPath pivotDirectory) { Argument.IsNotNull(nameof(pivotDirectory), pivotDirectory); string relativePath, failureMessage; if (!AbsoluteRelativePathHelpers.TryGetRelativePath(pivotDirectory, this, out relativePath, out failureMessage)) { throw new ArgumentException(failureMessage); } //Debug.Assert(pathRelative != null); //Debug.Assert(pathRelative.Length > 0); return(new RelativeFilePath(relativePath + MiscHelpers.DirectorySeparatorChar + FileName)); }