love.filesystem.getInfo

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
JayKyburz
Prole
Posts: 9
Joined: Wed May 19, 2021 10:47 pm

love.filesystem.getInfo

Post 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.
MrFariator
Party member
Posts: 548
Joined: Wed Oct 05, 2016 11:53 am

Re: love.filesystem.getInfo

Post 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.
JayKyburz
Prole
Posts: 9
Joined: Wed May 19, 2021 10:47 pm

Re: love.filesystem.getInfo

Post by JayKyburz »

Hey thanks, that was it!
JayKyburz
Prole
Posts: 9
Joined: Wed May 19, 2021 10:47 pm

Re: love.filesystem.getInfo

Post 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?
User avatar
EngineerSmith
Prole
Posts: 38
Joined: Thu Dec 02, 2021 11:38 am
Contact:

Re: love.filesystem.getInfo

Post 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"
MrFariator
Party member
Posts: 548
Joined: Wed Oct 05, 2016 11:53 am

Re: love.filesystem.getInfo

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests