about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-09-08 14:03:40 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-09-08 14:03:40 -0700
commit87ea2af2dabb2dca7908a4c0dd73305103849472 (patch)
treea225075306db5f6fba5c1962e0356efe17a67594
parente74b92b7333d3382277a6794833126d8e9ebd5cd (diff)
downloadlines.love-87ea2af2dabb2dca7908a4c0dd73305103849472.tar.gz
a few more testable file-system operations
-rw-r--r--app.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/app.lua b/app.lua
index b520077..8a7e0b2 100644
--- a/app.lua
+++ b/app.lua
@@ -290,12 +290,23 @@ function App.open_for_reading(filename)
       lines = function(self)
                 return App.filesystem[filename]:gmatch('[^\n]+')
               end,
+      read = function(self)
+               return App.filesystem[filename]
+             end,
       close = function(self)
               end,
     }
   end
 end
 
+function App.mkdir(dirname)
+  -- nothing in test mode
+end
+
+function App.remove(filename)
+  App.filesystem[filename] = nil
+end
+
 -- Some helpers to trigger an event and then refresh the screen. Akin to one
 -- iteration of the event loop.
 
@@ -435,6 +446,8 @@ function App.disable_tests()
         end
       end
   App.files = nativefs.getDirectoryItems
+  App.mkdir = nativefs.createDirectory
+  App.remove = nativefs.remove
   App.source_dir = love.filesystem.getSource()..'/'
   App.current_dir = nativefs.getWorkingDirectory()..'/'
   App.save_dir = love.filesystem.getSaveDirectory()..'/'