idk even anymore
This commit is contained in:
parent
7fa9171ba1
commit
febaaaacc7
13 changed files with 2239 additions and 1508 deletions
35
_helpers.lua
35
_helpers.lua
|
|
@ -32,6 +32,41 @@ function writeToSource(relPath, contents)
|
|||
return love.filesystem.write(relPath, contents)
|
||||
end
|
||||
|
||||
-- The editor occasionally needs to rename a source level after it has written
|
||||
-- the replacement. Keep that operation alongside writeToSource so packaged
|
||||
-- games still fall back to LÖVE's writable save directory.
|
||||
function removeFromSource(relPath)
|
||||
local base = love.filesystem.getSource()
|
||||
local path = base .. "/" .. relPath
|
||||
local file = io.open(path, "r")
|
||||
if file then
|
||||
file:close()
|
||||
return os.remove(path)
|
||||
end
|
||||
return love.filesystem.remove(relPath)
|
||||
end
|
||||
|
||||
-- Runtime saves live in LÖVE's write directory. This deliberately uses only
|
||||
-- love.filesystem operations: they cannot delete files from the source tree.
|
||||
function clearRuntimeSaveData()
|
||||
local removed = 0
|
||||
local function removeTree(path)
|
||||
if love.filesystem.isDirectory(path) then
|
||||
for _, child in ipairs(love.filesystem.getDirectoryItems(path)) do
|
||||
removeTree(path .. "/" .. child)
|
||||
end
|
||||
end
|
||||
if love.filesystem.remove(path) then removed = removed + 1 end
|
||||
end
|
||||
|
||||
-- These are the only files this game writes through love.filesystem: room
|
||||
-- autosaves and the generated asset cache. Source levels are read-only to
|
||||
-- this API and cannot be removed here.
|
||||
removeTree("rooms")
|
||||
if love.filesystem.remove("assets.prop") then removed = removed + 1 end
|
||||
return removed
|
||||
end
|
||||
|
||||
-- Read from the project tree directly so a stale copy in LÖVE's save directory
|
||||
-- can't shadow the real source file. Falls back to love.filesystem for a
|
||||
-- packaged .love.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue