/// <summary> /// Initializes a new instance of the <see cref="DotNetFileSystem"/> class. /// </summary> /// <param name="rootPath">The path to use as root</param> /// <param name="allowNonEmptyDirectoryDelete">Allow deletion of non-empty directories?</param> /// <param name="streamBufferSize">Buffer size to be used in async IO methods</param> public DotNetFileSystem(string rootPath, bool allowNonEmptyDirectoryDelete, int streamBufferSize) { FileSystemEntryComparer = StringComparer.OrdinalIgnoreCase; Root = new DotNetDirectoryEntry(this, Directory.CreateDirectory(rootPath), true); SupportsNonEmptyDirectoryDelete = allowNonEmptyDirectoryDelete; _streamBufferSize = streamBufferSize; }
/// <inheritdoc/> public Task<IUnixFileSystemEntry> GetEntryByNameAsync(IUnixDirectoryEntry directoryEntry, string name, CancellationToken cancellationToken) { var searchDirInfo = ((DotNetDirectoryEntry)directoryEntry).Info; var fullPath = Path.Combine(searchDirInfo.FullName, name); IUnixFileSystemEntry result; if (File.Exists(fullPath)) result = new DotNetFileEntry(this, new FileInfo(fullPath)); else if (Directory.Exists(fullPath)) result = new DotNetDirectoryEntry(this, new DirectoryInfo(fullPath), false); else result = null; return Task.FromResult(result); }
/// <inheritdoc/> public Task <IUnixFileSystemEntry> GetEntryByNameAsync(IUnixDirectoryEntry directoryEntry, string name, CancellationToken cancellationToken) { var searchDirInfo = ((DotNetDirectoryEntry)directoryEntry).Info; var fullPath = Path.Combine(searchDirInfo.FullName, name); IUnixFileSystemEntry result; if (File.Exists(fullPath)) { result = new DotNetFileEntry(this, new FileInfo(fullPath)); } else if (Directory.Exists(fullPath)) { result = new DotNetDirectoryEntry(this, new DirectoryInfo(fullPath), false); } else { result = null; } return(Task.FromResult(result)); }