123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using Zio;
- namespace TBL.GodotSharp.Content.FileSystem
- {
- public class NativeFileSystem : Zio.FileSystems.FileSystem
- {
- /// <summary>
- /// 根目录
- /// </summary>
- 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<UPath> 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<FileSystemItem> 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();
- }
- }
- }
|