Goals
- Make it easier to read/write absolute paths, since this is a common request.
- Make the virtual filesystem easier to understand. It seems to be causing more pain/confusion than the benefits you get from layering archives. This intends to replace the virtual filesystem with a combination of
Archive objects (for reading data from ZIP files) and @-aliases that can serve as a way to read data from common folder paths. This is a more explicit system that makes it clear which paths are being accessed. You can still recreate a virtual filesystem in Lua using Archive objects.
- Relative require. It comes up frequently and is painful.
- Ability to create ZIP archives, so we can add a
lovr --package . command.
- Miscellaneous things that have come up before: symlinks, drag-and-drop events.
Examples
-- Relative paths read from your source
lovr.filesystem.read('main.lua)
lovr.graphics.newTexture('texture.png')
-- @save folder
lovr.filesystem.write('gamestate.json', data) -- or @save/gamestate.json
lovr.filesystem.read('@save/gamestate.json')
-- Archive object
local archive = lovr.filesystem.newArchive('level.zip')
archive:getDirectoryItems('/')
archive:read('manifest.ini')
-- Relative require
local utils = require('./utils') -- TBD, maybe require('@local.utils'), '@self/utils', etc.
function lovr.filedropped(path)
--
end
Notes
Absolute Paths
Aliases
Archive
Symlinks
File Drop Events
Goals
Archiveobjects (for reading data from ZIP files) and @-aliases that can serve as a way to read data from common folder paths. This is a more explicit system that makes it clear which paths are being accessed. You can still recreate a virtual filesystem in Lua usingArchiveobjects.lovr --package .command.Examples
Notes
Absolute Paths
lf.write('file.txt', 'asdf')followed bylf.read('file.txt')to get the contents back. I think this is okay.Aliases
@source-lovr.filesystem.getSourceDirectory()@save-lovr.filesystem.getSaveDirectory()@executable-lovr.filesystem.getExecutablePath()with filename chopped off (just the directory)./and../in require paths (though it doesn't work when using dotted module names) or makerequireexpand aliases and add an alias that resolves to the directory containing the current file (@self?@parent?@dir?@local?)Archive
Archiveobject that can be used to access contents of ZIP files. It's readonly, and supports methods like:read,:getDirectoryItems,:getSize,:getLastModified.lovr.filesystem.compress({files}, destination)that creates a ZIP archive? Should be able to support both file paths and blob entries (maybe also strings). Would allow LÖVR to package projects.Symlinks
lovr.filesystem.are/setSymlinksEnabledlovr.filesystem.isSymlinkFile Drop Events
lovr.filedropped(path)eventglfwSetDropCallbackWM_DROPFILES