using System;
using System.Collections.Generic;
using System.IO;
using Zio;
namespace TBL.GodotSharp.Content.FileSystem
{
public class NativeFileSystem : Zio.FileSystems.FileSystem
{
///
/// 根目录
///
private readonly string _rootPath;
public NativeFileSystem(string rootPath)
{
_rootPath = rootPath;
}
private string GetFullPath(UPath uPath) => $"{_rootPath}{uPath}";
protected override bool DirectoryExistsImpl(UPath path) => Directory.Exists(GetFullPath(path));
protected override bool FileExistsImpl(UPath path) => File.Exists(GetFullPath(path));
protected override Stream OpenFileImpl(UPath path, FileMode mode, FileAccess access, FileShare share) =>
File.Open(GetFullPath(path), mode, access);
protected override IEnumerable EnumeratePathsImpl(
UPath path,
string searchPattern,
SearchOption searchOption,
SearchTarget searchTarget
)
{
if (searchTarget == SearchTarget.Both || searchTarget == SearchTarget.File)
foreach (var current in Directory.EnumerateFiles(GetFullPath(path), searchPattern, searchOption))
{
yield return current.Substring(_rootPath.Length);
}
if (searchTarget == SearchTarget.Both || searchTarget == SearchTarget.Directory)
foreach (var current in Directory.EnumerateDirectories(GetFullPath(path), searchPattern, searchOption))
{
yield return current.Substring(_rootPath.Length);
}
}
protected override void CreateDirectoryImpl(UPath path)
{
throw new NotImplementedException();
}
protected override void MoveDirectoryImpl(UPath srcPath, UPath destPath)
{
throw new NotImplementedException();
}
protected override void DeleteDirectoryImpl(UPath path, bool isRecursive)
{
throw new NotImplementedException();
}
protected override void CopyFileImpl(UPath srcPath, UPath destPath, bool overwrite)
{
throw new NotImplementedException();
}
protected override void ReplaceFileImpl(UPath srcPath, UPath destPath, UPath destBackupPath, bool ignoreMetadataErrors)
{
throw new NotImplementedException();
}
protected override long GetFileLengthImpl(UPath path)
{
throw new NotImplementedException();
}
protected override void MoveFileImpl(UPath srcPath, UPath destPath)
{
throw new NotImplementedException();
}
protected override void DeleteFileImpl(UPath path)
{
throw new NotImplementedException();
}
protected override FileAttributes GetAttributesImpl(UPath path)
{
throw new NotImplementedException();
}
protected override void SetAttributesImpl(UPath path, FileAttributes attributes)
{
throw new NotImplementedException();
}
protected override DateTime GetCreationTimeImpl(UPath path)
{
throw new NotImplementedException();
}
protected override void SetCreationTimeImpl(UPath path, DateTime time)
{
throw new NotImplementedException();
}
protected override DateTime GetLastAccessTimeImpl(UPath path)
{
throw new NotImplementedException();
}
protected override void SetLastAccessTimeImpl(UPath path, DateTime time)
{
throw new NotImplementedException();
}
protected override DateTime GetLastWriteTimeImpl(UPath path)
{
throw new NotImplementedException();
}
protected override void SetLastWriteTimeImpl(UPath path, DateTime time)
{
throw new NotImplementedException();
}
protected override IEnumerable EnumerateItemsImpl(UPath path, SearchOption searchOption, SearchPredicate searchPredicate)
{
throw new NotImplementedException();
}
protected override IFileSystemWatcher WatchImpl(UPath path)
{
throw new NotImplementedException();
}
protected override string ConvertPathToInternalImpl(UPath path)
{
throw new NotImplementedException();
}
protected override UPath ConvertPathFromInternalImpl(string innerPath)
{
throw new NotImplementedException();
}
}
}