Löve 11.1: love.filesystem.createDirectory( ) 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.
Post Reply
User avatar
molul
Party member
Posts: 255
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Löve 11.1: love.filesystem.createDirectory( ) doesn't seem to work

Post by molul » Wed Jun 13, 2018 8:53 am

I put these lines anywhere (for instance, in love.load() ):

local success = love.filesystem.createDirectory( "qwe" )
print ("CREATED? " .. ( success and "yes" or "no") )

And I always get "no".

Is there any parameter I'm missing?

randomnovice
Prole
Posts: 37
Joined: Sat May 09, 2015 9:15 pm

Re: Löve 11.1: love.filesystem.createDirectory( ) doesn't seem to work

Post by randomnovice » Wed Jun 13, 2018 4:28 pm

Just a guess (because I'm not sure what happens if you try to create a directory when it already exists) but have you looked in the defined save directory (check conf.lua) to see if the directory does exist now?

Code: Select all

if love.filesystem.getInfo("skins", "directory") == nil then love.filesystem.createDirectory("skins") end
Definitely works.

User avatar
molul
Party member
Posts: 255
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Re: Löve 11.1: love.filesystem.createDirectory( ) doesn't seem to work

Post by molul » Wed Jun 13, 2018 6:51 pm

Oh, I didn't know it would try to create it on the directory set by love.filesystem.setIdentity. I want to create it on the main.lua path.

However, love.filesystem.getInfo does check if the directory exists on the main.lua path. Not sure if it makes sense.

User avatar
Nixola
Inner party member
Posts: 1935
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Löve 11.1: love.filesystem.createDirectory( ) doesn't seem to work

Post by Nixola » Wed Jun 13, 2018 6:56 pm

LÖVE, by itself, won't ever try to write in the game archive (even when it's a folder and not an archive), but it will read from both there and the save directory, with the latter coming first. You can only write stuff to the save directory, and that includes creating directories.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics

User avatar
molul
Party member
Posts: 255
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Re: Löve 11.1: love.filesystem.createDirectory( ) doesn't seem to work

Post by molul » Thu Jun 14, 2018 6:11 am

Thanks for the info :)

However, I can't seem to make it work either. I added this line to my conf.lua:

t.identity = love.filesystem.getAppdataDirectory( ) .. "/myproject"

Then on love.load I have this:

Code: Select all

	print (love.filesystem.getIdentity(  )) -- <. to see the path is right

	local dataDir = love.filesystem.getInfo( love.filesystem.getIdentity(  ) )
	if (dataDir == nil) then
		local success = love.filesystem.createDirectory( love.filesystem.getIdentity(  ) )
		Common:PrintDebug ("Directory doesn't exist and was created: " .. ( success and "yes" or "no") )
	end
	
	local dataDir = love.filesystem.getInfo( "Data" )
	if (dataDir == nil) then
		local success = love.filesystem.createDirectory( "Data" )
		Common:PrintDebug ("Data directory doesn't exist and was created: " .. ( success and "yes" or "no") )
	end
I get no success for both directories. Can't create the "myproject" directory, neither the "Data" directory inside "myproject".


Also, this line on main.lua:
print (love.filesystem.getSaveDirectory())

Prints this:
C:/Users/luis/AppData/Roaming/LOVE/C:/Users/luis/AppData/Roaming/myproject

While this line:
print (love.filesystem.getIdentity( )) -- <. to see the path is right

Prints this:
C:/Users/luis/AppData/Roaming/myproject

So may I assume that any LÖVE project save directory is always under "C:/Users/luis/AppData/Roaming/LOVE/". Didn't see that in the documentation.
Last edited by molul on Thu Jun 14, 2018 6:17 am, edited 1 time in total.

User avatar
zorg
Party member
Posts: 2376
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Löve 11.1: love.filesystem.createDirectory( ) doesn't seem to work

Post by zorg » Thu Jun 14, 2018 6:15 am

You need to set t.identity to a singular string, which will be the relative path starting from löve's basic save directory; it won't take absolute paths.
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.

User avatar
molul
Party member
Posts: 255
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Re: Löve 11.1: love.filesystem.createDirectory( ) doesn't seem to work

Post by molul » Thu Jun 14, 2018 6:18 am

Oh sorry, I edited my post above before reading your reply. I understand now. Thanks! :)

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests