public static DirectoryInfo Combine(
     this DirectoryInfo directory,
     RelativeDirectoryPath directoryPath)
 {
     return(new DirectoryInfo(
                Path.Combine(
                    RelativePath.NormalizeDirectory(directory.FullName),
                    directoryPath.Value.Replace('/', Path.DirectorySeparatorChar))));
 }
Beispiel #2
0
        public void EnsureDirectoryExists(RelativeDirectoryPath path)
        {
            var fullyQualifiedPath = GetFullyQualifiedPath(path);

            if (!Directory.Exists(fullyQualifiedPath.FullName))
            {
                Directory.CreateDirectory(fullyQualifiedPath.FullName);
            }
        }
Beispiel #3
0
        public RelativeFilePath(string value) : base(value)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                throw new ArgumentException("File path cannot be null or consist entirely of whitespace", nameof(value));
            }

            var(directoryPath, fileName) = GetFileAndDirectoryNames(value);

            FileName = fileName;

            ThrowIfContainsDisallowedFilePathChars(FileName);

            Directory = new RelativeDirectoryPath(directoryPath);

            Value = Directory.Value + FileName;
        }
Beispiel #4
0
        public IDirectoryAccessor GetDirectoryAccessorForRelativePath(RelativeDirectoryPath relativePath)
        {
            var absolutePath = _rootDirectory.Combine(relativePath).FullName;

            return(new FileSystemDirectoryAccessor(new DirectoryInfo(absolutePath)));
        }
Beispiel #5
0
 public bool DirectoryExists(RelativeDirectoryPath path)
 {
     return(GetFullyQualifiedPath(path).Exists);
 }
Beispiel #6
0
 public static DirectoryInfo GetFullyQualifiedDirectoryPath(this IDirectoryAccessor directoryAccessor, RelativeDirectoryPath relativePath) =>
 (DirectoryInfo)directoryAccessor.GetFullyQualifiedPath(relativePath);