/// <inheritdoc /> public DirectoryPath GetContainingInputPath(NormalizedPath path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } if (path.IsAbsolute) { return(InputPaths .Reverse() .Select(x => RootPath.Combine(x)) .FirstOrDefault(x => x.FileProvider == path.FileProvider && (path.FullPath == x.Collapse().FullPath || path.FullPath.StartsWith(x.Collapse().FullPath + "/")))); } FilePath filePath = path as FilePath; if (filePath != null) { IFile file = GetInputFile(filePath); return(file.Exists ? GetContainingInputPath(file.Path) : null); } DirectoryPath directoryPath = path as DirectoryPath; if (directoryPath != null) { return(InputPaths .Reverse() .Select(x => new KeyValuePair <DirectoryPath, IDirectory>(x, GetRootDirectory(x.Combine(directoryPath)))) .Where(x => x.Value.Exists) .Select(x => RootPath.Combine(x.Key)) .FirstOrDefault()); } return(null); }
/// <inheritdoc /> public IFile GetInputFile(FilePath path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } if (path.IsRelative) { IFile notFound = null; foreach (DirectoryPath inputPath in InputPaths.Reverse()) { IFile file = GetFile(RootPath.Combine(inputPath).CombineFile(path)); if (notFound == null) { notFound = file; } if (file.Exists) { return(file); } } if (notFound == null) { throw new InvalidOperationException("The input paths collection must have at least one path"); } return(notFound); } return(GetFile(path)); }
/// <inheritdoc /> public FilePath GetTempPath(FilePath path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } return(RootPath.Combine(TempPath).CombineFile(path)); }
public IDirectory GetRootDirectory(DirectoryPath path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } return(GetDirectory(RootPath.Combine(path))); }
public IFile GetOutputFile(FilePath path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } return(GetFile(RootPath.Combine(OutputPath).CombineFile(path))); }
public string MapTo(RootPath root, string path) { if (this.Contains(path)) { string rel = this.GetRel(path); return(root.Combine(rel)); } else { throw new System.ArgumentOutOfRangeException("path", "does not contain this path"); } }
/// <inheritdoc /> public IDirectory GetRootDirectory(DirectoryPath path = null) => path == null ? GetDirectory(RootPath) : GetDirectory(RootPath.Combine(path));
/// <inheritdoc /> public DirectoryPath GetTempPath(DirectoryPath path = null) => path == null ? RootPath.Combine(TempPath) : RootPath.Combine(TempPath).Combine(path);
/// <inheritdoc /> public DirectoryPath GetOutputPath(DirectoryPath path = null) => path == null ? RootPath.Combine(OutputPath) : RootPath.Combine(OutputPath).Combine(path);