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