So say I have my folder. It has main.lua and test.txt, how can I write to that test.txt? I can read from it all nice and well, but I am unable to write to it. The wiki specifically says that the filesystem cannot do that, but I've also tried using io.open, with no luck (but that did work when I ran the lua code on its own, without using love). So how can I do this? The reason I want to do this is because it's just so much simpler to work with. I want to have my settings in the source itself, so I can put it anywhere and transfer it without having to do lots of tedious extra stuff every time.
So just to clarify, I want to overwrite an existing file in the source directory. Which should be pretty straight forward, even across platforms. How can I do this?
EDIT:
io.open gives me "permission denied" error, so I tried to run love with admin and then it worked. But this doesn't seem very nice. I suppose I could set the permission so I can always write, but then I'm back to the tedious bit, especially if I publish it.
Btw, this is on Windows 7.
How can I write to the source directory?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How can I write to the source directory?
Follow the potato. Achieve enlightenment.
- slime
- Solid Snayke
- Posts: 3132
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: How can I write to the source directory?
It's a feature of modern operating systems that the program needs special permissions to write to important places. In the grand scheme of things I'd rather it be like that than the alternative.Oysi wrote:io.open gives me "permission denied" error, so I tried to run love with admin and then it worked. But this doesn't seem very nice.
It's also one reason why there's only a single write directory in love.filesystem - there are only a few places that are writable all the time by programs on all operating systems, and of those few only one or two are really meant to be used for writing general program-specific files. LÖVE uses that location.
You could have a button or hotkey in your game/program to open an Explorer window showing the save directory:
Code: Select all
-- This will only work if the save directory actually exists (it gets created the first time a file is written by love.filesystem.)
function OpenSaveDirectory()
love.system.openURL("file://"..love.filesystem.getSaveDirectory())
end
Re: How can I write to the source directory?
Suck it up and deal with it, ok, got it.
=(
Thanks, though. At least now I know.
=(
Thanks, though. At least now I know.
Follow the potato. Achieve enlightenment.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: How can I write to the source directory?
That seems like a misinterpretation of the reply, it's more like "It's possible, but it's extremely painful; if you don't have to, don't."Oysi wrote:Suck it up and deal with it, ok, got it.
Who is online
Users browsing this forum: Ahrefs [Bot] and 203 guests