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

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.
User avatar
Clavus
Prole
Posts: 28
Joined: Wed Jan 27, 2010 12:45 pm

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

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post 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"
?
Help us help you: attach a .love.
User avatar
Clavus
Prole
Posts: 28
Joined: Wed Jan 27, 2010 12:45 pm

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

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post 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?
Help us help you: attach a .love.
User avatar
Clavus
Prole
Posts: 28
Joined: Wed Jan 27, 2010 12:45 pm

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

Post 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).
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

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

Post 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)
User avatar
Clavus
Prole
Posts: 28
Joined: Wed Jan 27, 2010 12:45 pm

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

Post 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.
User avatar
Clavus
Prole
Posts: 28
Joined: Wed Jan 27, 2010 12:45 pm

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

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post 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.
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

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

Post by bartbes »

If you enable the console, do you see any output?
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests