101 lines
2.9 KiB
C#
101 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using Tesses.VirtualFilesystem;
|
|
|
|
namespace Tesses.YouTubeDownloader.VFS
|
|
{
|
|
public class TYTDVFS : TYTDStorage
|
|
{
|
|
IVirtualFilesystem fs;
|
|
public TYTDVFS(IVirtualFilesystem fs)
|
|
{
|
|
this.fs =fs;
|
|
}
|
|
|
|
public override async Task<Stream> CreateAsync(string path)
|
|
{
|
|
return await fs.OpenAsync(path,FileMode.Create,FileAccess.Write,FileShare.Inheritable);
|
|
}
|
|
|
|
public override void CreateDirectory(string path)
|
|
{
|
|
fs.CreateDirectory(path);
|
|
}
|
|
|
|
public override void DeleteDirectory(string dir, bool recursive = false)
|
|
{
|
|
fs.DeleteDirectory(dir, recursive);
|
|
}
|
|
|
|
public override void DeleteFile(string file)
|
|
{
|
|
fs.DeleteFile(file);
|
|
}
|
|
|
|
public override async Task<bool> DirectoryExistsAsync(string path)
|
|
{
|
|
return await fs.DirectoryExistsAsync(path);
|
|
}
|
|
|
|
public override async IAsyncEnumerable<string> EnumerateDirectoriesAsync(string path)
|
|
{
|
|
await foreach(var dir in fs.EnumerateDirectoriesAsync(path))
|
|
{
|
|
yield return dir.Name;
|
|
}
|
|
}
|
|
|
|
public override async IAsyncEnumerable<string> EnumerateFilesAsync(string path)
|
|
{
|
|
await foreach(var file in fs.EnumerateFilesAsync(path))
|
|
{
|
|
yield return file.Name;
|
|
}
|
|
}
|
|
|
|
public override async Task<bool> FileExistsAsync(string path)
|
|
{
|
|
return await fs.FileExistsAsync(path);
|
|
}
|
|
|
|
public override void MoveDirectory(string src, string dest)
|
|
{
|
|
fs.MoveDirectory(src,dest);
|
|
}
|
|
|
|
public override async Task<Stream> OpenOrCreateAsync(string path)
|
|
{
|
|
return await fs.OpenAsync(path,FileMode.OpenOrCreate,FileAccess.ReadWrite,FileShare.Inheritable);
|
|
}
|
|
|
|
public override async Task<Stream> OpenReadAsync(string path)
|
|
{
|
|
return await fs.OpenAsync(path,FileMode.Open,FileAccess.Read,FileShare.Read);
|
|
}
|
|
|
|
public override void RenameFile(string src, string dest)
|
|
{
|
|
fs.MoveFile(src,dest);
|
|
}
|
|
public override IEnumerable<string> EnumerateDirectories(string path)
|
|
{
|
|
foreach(var item in fs.EnumerateDirectories(path)) yield return item.Name;
|
|
}
|
|
public override IEnumerable<string> EnumerateFiles(string path)
|
|
{
|
|
foreach(var item in fs.EnumerateFiles(path)) yield return item.Name;
|
|
|
|
}
|
|
public override bool DirectoryExists(string path)
|
|
{
|
|
return fs.DirectoryExists(path);
|
|
}
|
|
public new bool FileExists(string path)
|
|
{
|
|
return fs.FileExists(path);
|
|
}
|
|
}
|
|
}
|