NativeFileSystem.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using Zio;
  5. namespace TBL.GodotSharp.Content.FileSystem
  6. {
  7. public class NativeFileSystem : Zio.FileSystems.FileSystem
  8. {
  9. /// <summary>
  10. /// 根目录
  11. /// </summary>
  12. private readonly string _rootPath;
  13. public NativeFileSystem(string rootPath)
  14. {
  15. _rootPath = rootPath;
  16. }
  17. private string GetFullPath(UPath uPath) => $"{_rootPath}{uPath}";
  18. protected override bool DirectoryExistsImpl(UPath path) => Directory.Exists(GetFullPath(path));
  19. protected override bool FileExistsImpl(UPath path) => File.Exists(GetFullPath(path));
  20. protected override Stream OpenFileImpl(UPath path, FileMode mode, FileAccess access, FileShare share) =>
  21. File.Open(GetFullPath(path), mode, access);
  22. protected override IEnumerable<UPath> EnumeratePathsImpl(
  23. UPath path,
  24. string searchPattern,
  25. SearchOption searchOption,
  26. SearchTarget searchTarget
  27. )
  28. {
  29. if (searchTarget == SearchTarget.Both || searchTarget == SearchTarget.File)
  30. foreach (var current in Directory.EnumerateFiles(GetFullPath(path), searchPattern, searchOption))
  31. {
  32. yield return current.Substring(_rootPath.Length);
  33. }
  34. if (searchTarget == SearchTarget.Both || searchTarget == SearchTarget.Directory)
  35. foreach (var current in Directory.EnumerateDirectories(GetFullPath(path), searchPattern, searchOption))
  36. {
  37. yield return current.Substring(_rootPath.Length);
  38. }
  39. }
  40. protected override void CreateDirectoryImpl(UPath path)
  41. {
  42. throw new NotImplementedException();
  43. }
  44. protected override void MoveDirectoryImpl(UPath srcPath, UPath destPath)
  45. {
  46. throw new NotImplementedException();
  47. }
  48. protected override void DeleteDirectoryImpl(UPath path, bool isRecursive)
  49. {
  50. throw new NotImplementedException();
  51. }
  52. protected override void CopyFileImpl(UPath srcPath, UPath destPath, bool overwrite)
  53. {
  54. throw new NotImplementedException();
  55. }
  56. protected override void ReplaceFileImpl(UPath srcPath, UPath destPath, UPath destBackupPath, bool ignoreMetadataErrors)
  57. {
  58. throw new NotImplementedException();
  59. }
  60. protected override long GetFileLengthImpl(UPath path)
  61. {
  62. throw new NotImplementedException();
  63. }
  64. protected override void MoveFileImpl(UPath srcPath, UPath destPath)
  65. {
  66. throw new NotImplementedException();
  67. }
  68. protected override void DeleteFileImpl(UPath path)
  69. {
  70. throw new NotImplementedException();
  71. }
  72. protected override FileAttributes GetAttributesImpl(UPath path)
  73. {
  74. throw new NotImplementedException();
  75. }
  76. protected override void SetAttributesImpl(UPath path, FileAttributes attributes)
  77. {
  78. throw new NotImplementedException();
  79. }
  80. protected override DateTime GetCreationTimeImpl(UPath path)
  81. {
  82. throw new NotImplementedException();
  83. }
  84. protected override void SetCreationTimeImpl(UPath path, DateTime time)
  85. {
  86. throw new NotImplementedException();
  87. }
  88. protected override DateTime GetLastAccessTimeImpl(UPath path)
  89. {
  90. throw new NotImplementedException();
  91. }
  92. protected override void SetLastAccessTimeImpl(UPath path, DateTime time)
  93. {
  94. throw new NotImplementedException();
  95. }
  96. protected override DateTime GetLastWriteTimeImpl(UPath path)
  97. {
  98. throw new NotImplementedException();
  99. }
  100. protected override void SetLastWriteTimeImpl(UPath path, DateTime time)
  101. {
  102. throw new NotImplementedException();
  103. }
  104. protected override IEnumerable<FileSystemItem> EnumerateItemsImpl(UPath path, SearchOption searchOption, SearchPredicate searchPredicate)
  105. {
  106. throw new NotImplementedException();
  107. }
  108. protected override IFileSystemWatcher WatchImpl(UPath path)
  109. {
  110. throw new NotImplementedException();
  111. }
  112. protected override string ConvertPathToInternalImpl(UPath path)
  113. {
  114. throw new NotImplementedException();
  115. }
  116. protected override UPath ConvertPathFromInternalImpl(string innerPath)
  117. {
  118. throw new NotImplementedException();
  119. }
  120. }
  121. }