Browse Source

rename: rename ILuaFileManager to ILuaFileSystem and update references

Akeit0 7 months ago
parent
commit
c784577d84

+ 3 - 3
src/Lua/ILuaFileManager.cs → src/Lua/ILuaFileSystem.cs

@@ -1,6 +1,6 @@
 namespace Lua;
 
-public interface ILuaFileManager
+public interface ILuaFileSystem
 {
     public bool IsReadable(string path);
     public ValueTask<LuaFileContent> ReadFileContentAsync(string path, CancellationToken cancellationToken);
@@ -41,9 +41,9 @@ public interface IStreamWriter : IDisposable
     public void SetVBuf(string mode, int size);
 }
 
-public sealed class SystemFileManager : ILuaFileManager
+public sealed class FileSystem : ILuaFileSystem
 {
-    public static readonly SystemFileManager Instance = new();
+    public static readonly FileSystem Instance = new();
 
     public bool IsReadable(string path)
     {

+ 1 - 1
src/Lua/LuaState.cs

@@ -38,7 +38,7 @@ public sealed class LuaState
 
     public ILuaModuleLoader ModuleLoader { get; set; } = FileModuleLoader.Instance;
     
-    public ILuaFileManager FileManager { get; set; } = SystemFileManager.Instance;
+    public ILuaFileSystem FileSystem { get; set; } = Lua.FileSystem.Instance;
 
     // metatables
     LuaTable? nilMetatable;

+ 1 - 1
src/Lua/LuaStateExtensions.cs

@@ -29,7 +29,7 @@ public static class LuaStateExtensions
         var name = "@" + fileName;
         LuaClosure closure;
         {
-            using var file = await state.FileManager.ReadFileContentAsync(fileName, cancellationToken);
+            using var file = await state.FileSystem.ReadFileContentAsync(fileName, cancellationToken);
             closure = file.Type == LuaFileContentType.Bytes
                 ? state.Load(file.ReadBytes(), name, mode, environment)
                 : state.Load(file.ReadText(), name, environment);

+ 2 - 2
src/Lua/Standard/IOLibrary.cs

@@ -74,7 +74,7 @@ public sealed class IOLibrary
         }
         else
         {
-            var stream = context.State.FileManager.Open(arg.ToString()!, FileMode.Open, FileAccess.ReadWrite);
+            var stream = context.State.FileSystem.Open(arg.ToString()!, FileMode.Open, FileAccess.ReadWrite);
             var handle = new FileHandle(stream);
             registry["stdin"] = new(handle);
             return new(context.Return(new LuaValue(handle)));
@@ -158,7 +158,7 @@ public sealed class IOLibrary
         }
         else
         {
-            var stream = context.State.FileManager.Open(arg.ToString()!, FileMode.Open, FileAccess.ReadWrite);
+            var stream = context.State.FileSystem.Open(arg.ToString()!, FileMode.Open, FileAccess.ReadWrite);
             var handle = new FileHandle(stream);
             io["stdout"] = new(handle);
             return new(context.Return(new LuaValue(handle)));

+ 1 - 1
src/Lua/Standard/Internal/IOHelper.cs

@@ -24,7 +24,7 @@ internal static class IOHelper
 
         try
         {
-            var stream = thread.State.FileManager.Open(fileName, fileMode, fileAccess);
+            var stream = thread.State.FileSystem.Open(fileName, fileMode, fileAccess);
             thread.Stack.Push(new LuaValue(new FileHandle(stream)));
             return 1;
         }

+ 1 - 1
src/Lua/Standard/ModuleLibrary.cs

@@ -71,7 +71,7 @@ public sealed class ModuleLibrary
         {
             path = pathSpan[..nextIndex].ToString();
             var fileName = path.Replace("?", name);
-            if (state.FileManager.IsReadable(fileName))
+            if (state.FileSystem.IsReadable(fileName))
             {
                 return fileName;
             }