Small cleanup to file info checking

This commit is contained in:
Ishaan Bhardwaj 2021-06-03 16:00:33 -04:00
parent 6c201596b0
commit 56fb5aebea
2 changed files with 6 additions and 4 deletions

View File

@ -1,8 +1,10 @@
local binser = require 'libs.binser' local binser = require 'libs.binser'
function loadSave() function loadSave()
local info = love.filesystem.getInfo(love.filesystem.getSaveDirectory()) local info = love.filesystem.getInfo(
if not info or info.type ~= "directory" then love.filesystem.getSaveDirectory(), "directory"
)
if not info then
love.filesystem.remove(love.filesystem.getSaveDirectory()) love.filesystem.remove(love.filesystem.getSaveDirectory())
love.filesystem.createDirectory(love.filesystem.getSaveDirectory()) love.filesystem.createDirectory(love.filesystem.getSaveDirectory())
end end

View File

@ -99,8 +99,8 @@ function love.keypressed(key, scancode)
-- f12 is reserved for saving screenshots -- f12 is reserved for saving screenshots
elseif scancode == "f12" then elseif scancode == "f12" then
local ss_name = os.date("ss/%Y-%m-%d_%H-%M-%S.png") local ss_name = os.date("ss/%Y-%m-%d_%H-%M-%S.png")
local info = love.filesystem.getInfo("ss") local info = love.filesystem.getInfo("ss", "directory")
if not info or info.type ~= "directory" then if not info then
love.filesystem.remove("ss") love.filesystem.remove("ss")
love.filesystem.createDirectory("ss") love.filesystem.createDirectory("ss")
end end