internal static bool TryGetRelativePath(IAbsoluteDirectoryPath pathFrom, IAbsolutePath pathTo, out string relativePath, out string failureMessage) { //Argument.IsNotNull(nameof(pathFrom), pathFrom); //Argument.IsNotNull(nameof(pathTo), pathTo); if (!pathFrom.OnSameVolumeThan(pathTo)) { failureMessage = @"Cannot compute relative path from 2 paths that are not on the same volume PathFrom = """ + pathFrom + @""" PathTo = """ + pathTo + @""""; relativePath = null; return(false); } // Only work with Directory if (pathTo.IsFilePath) { pathTo = pathTo.ParentDirectoryPath; } relativePath = GetPathRelativeTo(pathFrom.ToString(), pathTo.ToString()); failureMessage = null; return(true); }
// // Relative/absolute computation // internal static bool TryGetRelativePath(IAbsoluteDirectoryPath pathFrom, IAbsolutePath pathTo, out string pathResult, out string failurereason) { Debug.Assert(pathFrom != null); Debug.Assert(pathTo != null); if (!pathFrom.OnSameVolumeThan(pathTo)) { failurereason = @"Cannot compute relative path from 2 paths that are not on the same volume PathFrom = """ + pathFrom.ToString() + @""" PathTo = """ + pathTo.ToString() + @""""; pathResult = null; return false; } // Only work with Directory if (pathTo.IsFilePath) { pathTo = pathTo.ParentDirectoryPath; } pathResult = GetPathRelativeTo(pathFrom.ToString(), pathTo.ToString()); failurereason = null; return true; }
// // Relative/absolute computation // internal static bool TryGetRelativePath(IAbsoluteDirectoryPath pathFrom, IAbsolutePath pathTo, out string pathResult, out string failurereason) { Debug.Assert(pathFrom != null); Debug.Assert(pathTo != null); if (!pathFrom.OnSameVolumeThan(pathTo)) { failurereason = @"Cannot compute relative path from 2 paths that are not on the same volume PathFrom = """ + pathFrom.ToString() + @""" PathTo = """ + pathTo.ToString() + @""""; pathResult = null; return(false); } // Only work with Directory if (pathTo.IsFilePath) { pathTo = pathTo.ParentDirectoryPath; } pathResult = GetPathRelativeTo(pathFrom.ToString(), pathTo.ToString()); failurereason = null; return(true); }
internal static bool TryGetRelativePath(IAbsoluteDirectoryPath pathFrom, IAbsolutePath pathTo, out string relativePath, out string failureMessage) { //Argument.IsNotNull(nameof(pathFrom), pathFrom); //Argument.IsNotNull(nameof(pathTo), pathTo); if (!pathFrom.OnSameVolumeThan(pathTo)) { failureMessage = @"Cannot compute relative path from 2 paths that are not on the same volume PathFrom = """ + pathFrom + @""" PathTo = """ + pathTo + @""""; relativePath = null; return false; } // Only work with Directory if (pathTo.IsFilePath) { pathTo = pathTo.ParentDirectoryPath; } relativePath = GetPathRelativeTo(pathFrom.ToString(), pathTo.ToString()); failureMessage = null; return true; }