Page 1 of 2

love.filesystem trouble, doesn't seem to work.

Posted: Wed Jan 27, 2010 8:04 pm
by Clavus
I've got this function (gets called in love.load) for reading a configuration text file.

Code: Select all

local function LoadConfig()
	
	local CONFIG_FILE = love.filesystem.getSaveDirectory().."/config.txt"
	
	print("Attempting to load config")
	print("File path: "..CONFIG_FILE)
	local cfgfile = nil
	if (love.filesystem.exists(CONFIG_FILE)) then
		cfgfile = love.filesystem.newFile(CONFIG_FILE)
	else
		print("a")
		if (love.filesystem.write(CONFIG_FILE, DefaultConfigString())) then
			print("b")
			cfgfile = love.filesystem.newFile(CONFIG_FILE)
		else
			print("c")
			error("Can't read and/or create config.txt file.")
		end
	end
	
	for k, v in pairs(cfgfile:lines()) do
		print("Line "..k.." = "..v)
	end

end

local function DefaultConfigString()

	return [[m1 +primary
			m2 +secondary
			w +forward
			a +left
			d +right
			s +back]]
end
Notice the part where it says print("a"). After that, it executes NEITHER print("b") or print("c"), the function just ended, so the only thing I can assume is that it just stops dead at love.filesystem.write, without giving a warning or error of any kind. I also noticed the CONFIG_FILE path name contained "C:/Users/.." instead of "C:/Gebruikers/..." (Dutch language pack, I'm on Windows 7 Enterprise) which my file system uses, although I don't know if that matters.

Re: love.filesystem trouble, doesn't seem to work.

Posted: Wed Jan 27, 2010 8:41 pm
by Robin
You don't have to use love.filesystem.getSaveDirectory(). (Or rather: you can't use that. I know, it's odd.)

What happens if you change line 3 to:

Code: Select all

   local CONFIG_FILE = "config.txt"
?

Re: love.filesystem trouble, doesn't seem to work.

Posted: Wed Jan 27, 2010 9:04 pm
by Clavus
Doesn't work either. Also, I don't see the save directory being created in the AppData/Roaming/LOVE/ folder, like the path indicates. I did use the love.filesystem.setIdentity( "gamename" ) in love.load earlier.

Re: love.filesystem trouble, doesn't seem to work.

Posted: Wed Jan 27, 2010 9:21 pm
by Robin
Clavus wrote:I also noticed the CONFIG_FILE path name contained "C:/Users/.." instead of "C:/Gebruikers/..." (Dutch language pack, I'm on Windows 7 Enterprise) which my file system uses, although I don't know if that matters.
This may be the source of the problems. Does C:/Users/... exist on your system?

Re: love.filesystem trouble, doesn't seem to work.

Posted: Wed Jan 27, 2010 9:37 pm
by Clavus
Robin wrote:
Clavus wrote:I also noticed the CONFIG_FILE path name contained "C:/Users/.." instead of "C:/Gebruikers/..." (Dutch language pack, I'm on Windows 7 Enterprise) which my file system uses, although I don't know if that matters.
This may be the source of the problems. Does C:/Users/... exist on your system?
Nope. And because this is so, it might be that love.filesystem.setIdentity isn't functioning either (thus the reason that there is no save folder).

Re: love.filesystem trouble, doesn't seem to work.

Posted: Wed Jan 27, 2010 10:17 pm
by bartbes
The path is supposed to be extracted from your environment variables, try finding the one that points to C:\\Users and change it to C:\\Gebruikers. (though I must say I am horrified by them even thinking about localizing such paths, microsoft never ceases to amaze me)

Re: love.filesystem trouble, doesn't seem to work.

Posted: Wed Jan 27, 2010 10:48 pm
by Clavus
bartbes wrote:The path is supposed to be extracted from your environment variables, try finding the one that points to C:\\Users and change it to C:\\Gebruikers. (though I must say I am horrified by them even thinking about localizing such paths, microsoft never ceases to amaze me)
On the other hand, if I type C:/Users/<myname>/AppData in the explorer bar, it does direct me to the right place. The translations might just be aliases. The problem is probably somewhere else.

Re: love.filesystem trouble, doesn't seem to work.

Posted: Fri Jan 29, 2010 8:44 pm
by Clavus
No other suggestions on what I could be doing wrong? :(

I made sure that Love.exe is run as administrator, in case that might've caused why no save directory is being created, but alas.

Re: love.filesystem trouble, doesn't seem to work.

Posted: Fri Jan 29, 2010 9:25 pm
by Robin
Clavus wrote:I made sure that Love.exe is run as administrator, in case that might've caused why no save directory is being created, but alas.
That shouldn't be necessary. LÖVE feels very much at on Linux, where requiring for a program to "run as administrator" when not really needed is considered a deadly sin.

Re: love.filesystem trouble, doesn't seem to work.

Posted: Fri Jan 29, 2010 9:27 pm
by bartbes
If you enable the console, do you see any output?