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

            if (!Directory.Exists(fullyQualifiedPath.FullName))
            {
                Directory.CreateDirectory(fullyQualifiedPath.FullName);
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 4
0
        public IDirectoryAccessor GetDirectoryAccessorForRelativePath(RelativeDirectoryPath relativePath)
        {
            var absolutePath = _rootDirectory.Combine(relativePath).FullName;

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