love.filesystem.getInfo() Searching only game files and not Save files

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
MoodyH8s
Prole
Posts: 2
Joined: Thu Nov 19, 2020 9:11 pm

love.filesystem.getInfo() Searching only game files and not Save files

Post by MoodyH8s »

When I do this

Code: Select all

if love.filesystem.getInfo('options.txt') == nil then
        file = love.filesystem.createDirectory('options')  
getInfo searches for options.txt inside the same directory that main.lua instead of the SaveDIrectory and createDirectory creates
the folder in the SaveDirectory.

when I write this

Code: Select all

love.filesystem.getSaveDirectory( )
it outputs the correct saveDirectory, within appdata, but getInfo does not search there.

So my question ultimately is , how do I search if a file exists inside of the savedirectory. How do I search the saveDirectory

I have looked online and in the documentation , but they all assume that getInfo IS searchingin the saveDirectory.

Thanks in advance!
User avatar
pgimeno
Party member
Posts: 3684
Joined: Sun Oct 18, 2015 2:58 pm

Re: love.filesystem.getInfo() Searching only game files and not Save files

Post by pgimeno »

The following main.lua works for me:

Code: Select all

love.filesystem.write('abc.txt', 'abc')

function love.draw()
  love.graphics.print(love.filesystem.getInfo('abc.txt').type)
end
There may be something you're not doing properly, but we can't do much with that little information.
User avatar
zorg
Party member
Posts: 3470
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: love.filesystem.getInfo() Searching only game files and not Save files

Post by zorg »

It is, and even if you have a file with the same name and path in both your save directories AND the game's directory (relative to main.lua), by default, precedence goes to the save directory... the only two things i can think of is either
- you didn't set an identity for your project, so there's no save directory, and/or
- you changed the precedence of the save folder to come after where main.lua is.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
MoodyH8s
Prole
Posts: 2
Joined: Thu Nov 19, 2020 9:11 pm

Re: love.filesystem.getInfo() Searching only game files and not Save files

Post by MoodyH8s »

zorg wrote: Fri Nov 20, 2020 4:41 pm It is, and even if you have a file with the same name and path in both your save directories AND the game's directory (relative to main.lua), by default, precedence goes to the save directory... the only two things i can think of is either
- you didn't set an identity for your project, so there's no save directory, and/or
- you changed the precedence of the save folder to come after where main.lua is.
I 100% thought the exact same thing as you did , I really did try and understand this completely. It completely works fine with using an outdated love.filesytem.exists. It works completely fine with 0 issues as intended. All other older seperated versions of getInfo() work just fine, but getInfo does not.

Edit: WHILE I WAS WRITING THIS. my exact code up there started working. I have not changed any directories since it wasn't working. I checked all Directories by printing them and everything has been the same. I don't know why it started working but I can say that it probably something I did and hopefully never have to deal with something like that again.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot] and 14 guests