Loading files outside the .love file

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
Atolm
Prole
Posts: 3
Joined: Fri Nov 25, 2011 4:24 pm

Loading files outside the .love file

Post by Atolm »

Hey, looking for some help.

I need to load a file outside the .love folder (basically an .ini file that allows the user to configure some stuff outside the game). I'll be compiling to an .exe, but the user needs to be able to edit this file, so it's got to go outside the project directory. The file just shares a folder with the .love (or complied .exe) so I was pretty stumped when "../filename" didn't locate it, so I did some digging around and apparently Love has issues loading stuff that's not in the project directory, or the write directory... and I can't specify the file path for the write directory, just a name?

Would it be possible to set the write directory to some known location (ideally the folder that contains the .exe) so it can read the .ini from there? Or is there something more obvious that I'm missing?

Thanks.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Loading files outside the .love file

Post by tentus »

From the wiki:
Each game is granted a single directory on the system where files can be saved through love.filesystem. This is the only directory where love.filesystem can write files.
This is mostly for security reasons. Also, we've been getting a lot of questions about ini files recently... just so you know, .lua files make more sense, though it really is just semantics.
Kurosuke needs beta testers
Atolm
Prole
Posts: 3
Joined: Fri Nov 25, 2011 4:24 pm

Re: Loading files outside the .love file

Post by Atolm »

Security reasons? Well, anyway, is it possible to set up the write directory so that it contains the project folder? That is, the write directory would be the folder that is distributed, and it would contain the .exe and also the .ini to read data from? I can't really work out where the write directory is located and how to specify it's path.

Also, I was sure I posted this on the development board! Can it be moved?
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Loading files outside the .love file

Post by thelinx »

Writing to the actual game folder is a bad idea on any platform that isn't Windows XP.
You need administrator rights to write to that folder on any other system. Storing data in appdata is what appdata is there for.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests