Page 1 of 1

love.filesystem.getInfo

Posted: Wed Jan 26, 2022 4:18 am
by JayKyburz
Can anybody confirm this functions works on Ubuntu. Seems to return nil no-matter what.

Code: Select all

	-- the continue button
	local continuePath = love.filesystem.getSaveDirectory().."/continue.lua"
	print ("Looking for Continue in ".. continuePath)
	local fileInfo = love.filesystem.getInfo(continuePath)
	
	if fileInfo then 
		-- restore from auto save like this
		log("Continuing...")
		App.game = App.LoadGameFromFile("continue")
	else
		log("New Game...")
		-- load new battle like this
		App.game = App.LoadGameFromSenario("orcBattle")
	end
The save file is there and will load fine if I remove the check.

Re: love.filesystem.getInfo

Posted: Wed Jan 26, 2022 4:47 am
by MrFariator
I'm not sure if absolute paths work with getInfo, since I've always used relative paths, so try with just

Code: Select all

local fileInfo = love.filesystem.getInfo("continue.lua")
You'll also need to make sure that you've set your game's identity properly in your conf.lua. If you want to make sure that getInfo checks save directory before source directory (in case you have conflicting file names), make sure appendidentity is set to false.

Re: love.filesystem.getInfo

Posted: Wed Jan 26, 2022 9:34 am
by JayKyburz
Hey thanks, that was it!

Re: love.filesystem.getInfo

Posted: Wed Jan 26, 2022 9:35 am
by JayKyburz
Do you think I should make a note in this wiki?

https://love2d.org/wiki/love.filesystem.getInfo

Is that the docs that most people use?

Re: love.filesystem.getInfo

Posted: Wed Jan 26, 2022 1:41 pm
by EngineerSmith
It is already a note on https://love2d.org/wiki/love.filesystem it's a little hidden at the bottom; being the 2nd paragraph from the bottom before "Types"

Re: love.filesystem.getInfo

Posted: Wed Jan 26, 2022 4:36 pm
by MrFariator
I think for redundancy it wouldn't be a bad idea to make a mention of it on some of the relevant function pages, like getInfo, or at least a warning on getSaveDirectory.

getSaveDirectory is mostly intended for things like using external file system code or libraries (in case the sandboxed environment of love.filesystem doesn't suit your needs), or maybe even if you want your game to open a file browser window in the desired location with love.system.openURL. As such, a proper note on how the absolute path getSaveDirectory returns won't work with the other usual love.filesystem functions might be warranted.