love.filesystem

Provides an interface to the user’s filesystem.

This module provides access to files in specific places:

  • The root folder of the .love archive (or source directory)
  • The root folder of the game’s save directory.
  • The folder containing the game’s .love archive (or source directory), but only if specific conditions are met.

Save data will always be written next to the application.
If the app is not fused (compiled into a ROMFS with LÖVE Potion), it is in {CURRENT_DIRECTORY}/save/{identity}. Otherwise, it will be under {CURRENT_DIRECTORY}/save

{CURRENT_DIRECTORY} is the directory containing the application (3dsx or nro)

</b></i>

?> You can also access files on the SD Card itself using the standard io library!

Functions

Name Description Notes
init Initializes love.filesystem, will be called internally, so should not be used explictly  
append Append data to an existing file  
createDirectory Creates a directory  
getDirectoryItems Returns all the files and subdirectories in the directory  
getIdentity Gets the write directory name for your game  
getInfo Gets information about the specified file or directory  
getRealDirectory Gets the absolute path of the directory containing a filepath  
getRequirePath Gets the filesystem paths that will be searched when require is called  
getSaveDirectory Gets the full path to the designated save directory  
getSourceBaseDirectory Returns the full path to the directory containing the .love file  
getSource Returns the full path to the .love file or directory  
getUserDirectory Returns the path of the user’s directory  
getWorkingDirectory Gets the current working directory  
isFused Gets whether the game is in fused mode or not  
lines Iterate over the lines in a file  
load Loads a Lua file (but does not run it)  
mount Mounts a zip file or folder in the game’s save directory for reading  
newFile Creates a new File object  
newFileData Creates a new FileData object from a file on disk, or from a string in memory  
read Read the contents of a file  
remove Removes a file (or directory)  
setIdentity Sets the write directory for your game  
setRequirePath Sets the filesystem paths that will be searched when require is called  
setSource Sets the source of the game, where the code is present; used internally  
unmount Unmounts a zip file or folder previously mounted with love.filesystem.mount  
write Write data to a file  

Types

File

Represents a file on the filesystem. A function that takes a file path can also take a File </b>

See also:

Name Description Notes
close Closes a File  
flush Flushes any buffered written data in the file to disk  
getBuffer Gets the buffer mode of a file  
getFilename Gets the filename that the File object was created with  
getMode Gets the FileMode the file has been opened with  
getSize Returns the File’s size  
isEOF Gets whether end-of-file has been reached  
isOpen Gets whether the file is open  
lines Iterate over all the lines in a file  
open Open the file for write, read or append  
read Read a number of bytes from a file  
seek Seek to a position in a file  
setBuffer Sets the buffer mode for a file opened for writing or appending  
tell Returns the position in the file  
write Write data to a file  

FileData

Data representing the contents of a file </b>

See also:

Name Description Notes
clone Creates a new copy of the Data object  
getFilename Gets the filename of the FileData  
getExtension Gets the extension of the FileData