how to use the love.filesystem

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
MrFariator
Party member
Posts: 512
Joined: Wed Oct 05, 2016 11:53 am

Re: how to use the love.filesystem

Post by MrFariator »

You can not create, save or delete files under the working directory. Löve's filesystem is sandboxed, meaning that it will only perform file modifications under your löve project's save directory (but it will still load files from working directory). You can get said directory's location with love.filesystem.getSaveDirectory, and in order to save or create files under it all you need to feed to the function is the folder name.

Code: Select all

-- creates a folder called "log" in save directory
-- if one doesn't exist
love.filesystem.createDirectory( "log" )

-- recursively creates a folder "user", and inside
-- it a folder called "profile", if they do not exist
love.filesystem.createDirectory( "user/profile" )
Another problem possibly is that I don't think love.filesystem.createDirectory allows strings that begin with "./", as it would attempt to create a folder with the name ".". However, something like ".log/something" would work.
sphyrth
Party member
Posts: 260
Joined: Mon Jul 07, 2014 11:04 am
Contact:

Re: how to use the love.filesystem

Post by sphyrth »

If you want to see love.filesystem at work, you have to put out the .love executable for each OS, and test them. It works differently in development mode.

It's my current gripe, but I just settle with using the defaults and let love2d do all the filesystem work by itself in each OS.
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: how to use the love.filesystem

Post by zorg »

sphyrth wrote: Fri Aug 28, 2020 1:37 am If you want to see love.filesystem at work, you have to put out the .love executable for each OS, and test them. It works differently in development mode.
It works even if you don't package your project in any way, the path will just omit the LOVE subdirectory part right before your project's identity... (not sure if it's in all cases or just when löve is fused to an .exe though)
that said, you could use a library to write anywhere, specifically this one: https://github.com/megagrump/nativefs
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.
Post Reply

Who is online

Users browsing this forum: No registered users and 86 guests