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'
function loadSave()
local info = love.filesystem.getInfo(love.filesystem.getSaveDirectory())
if not info or info.type ~= "directory" then
local info = love.filesystem.getInfo(
love.filesystem.getSaveDirectory(), "directory"
)
if not info then
love.filesystem.remove(love.filesystem.getSaveDirectory())
love.filesystem.createDirectory(love.filesystem.getSaveDirectory())
end

View File

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