new primitives for reading/writing files

[?]
Sep 9, 2023, 3:56 PM
FQURPLDAJ23WHRCFKBL3UFDL2MAQIJ7NIOXS7H6MLOGLW2QB33UAC

Dependencies

  • [2] C4YSIYPO reorder
  • [*] 3QNOKBFM beginnings of a test harness
  • [*] CUFW4EJL reorganize app.lua and its comments
  • [*] HOWVSTWA a few more testable file-system operations
  • [*] ED4Z6ORC cleaner API for file-system access
  • [*] HKV72RZV bugfix: save modified files in save directory

Change contents

  • edit in app.lua at line 291
    [5.5001]
    [2.36]
    function App.read_file(filename)
    return App.filesystem[filename]
    end
  • edit in app.lua at line 306
    [2.288]
    [6.130]
    function App.write_file(filename, contents)
    App.filesystem[filename] = contents
    return --[[status]] true
    end
  • edit in app.lua at line 445
    [7.16250]
    [8.624]
    end
    end
    App.read =
    function(path)
    if not is_absolute_path(path) then
    return --[[status]] false, 'Please use an unambiguous absolute path.'
    end
    local f, err = App.open_for_reading(path)
    if err then
    return --[[status]] false, err
  • edit in app.lua at line 456
    [8.636]
    [7.16251]
    local contents = f:read()
    f:close()
    return contents
  • edit in app.lua at line 470
    [7.16494]
    [7.16494]
    App.write =
    function(filename, contents)
    if not is_absolute_path(path) then
    return --[[status]] false, 'Please use an unambiguous absolute path.'
    end
    local f, err = App.open_for_writing(filename)
    if err then
    return --[[status]] false, err
    end
    f:write(contents)
    f:close()
    end