Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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));
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public FilePath GetTempPath(FilePath path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            return(RootPath.Combine(TempPath).CombineFile(path));
        }
Exemplo n.º 4
0
        public IDirectory GetRootDirectory(DirectoryPath path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            return(GetDirectory(RootPath.Combine(path)));
        }
Exemplo n.º 5
0
        public IFile GetOutputFile(FilePath path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            return(GetFile(RootPath.Combine(OutputPath).CombineFile(path)));
        }
Exemplo n.º 6
0
 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");
     }
 }
Exemplo n.º 7
0
 /// <inheritdoc />
 public IDirectory GetRootDirectory(DirectoryPath path = null) =>
 path == null
     ? GetDirectory(RootPath)
     : GetDirectory(RootPath.Combine(path));
Exemplo n.º 8
0
 /// <inheritdoc />
 public DirectoryPath GetTempPath(DirectoryPath path = null) =>
 path == null
         ? RootPath.Combine(TempPath)
         : RootPath.Combine(TempPath).Combine(path);
Exemplo n.º 9
0
 /// <inheritdoc />
 public DirectoryPath GetOutputPath(DirectoryPath path = null) =>
 path == null
         ? RootPath.Combine(OutputPath)
         : RootPath.Combine(OutputPath).Combine(path);