love.filesystem

Provides an interface to the user's filesystem.

This module provides access to Files in two places, and two places only:

  • The root folder of the .love archive (or source directory)
  • The root folder of the game's save directory.

Each game is granted a single directory on the system where files can be saved through love.filesystem. This is the only directory where love.filesystem can write files. These directories will typically be found in something like:

  • Windows XP: C:\Documents and Settings\user\Application Data\Love\ or %appdata%\Love\
  • Windows Vista and 7: C:\Users\user\AppData\Roaming\LOVE or %appdata%\Love\
  • Linux: $XDG_DATA_HOME/love/ or ~/.local/share/love/
  • mac: /Users/user/Library/Application Support/LOVE/

Files that are opened for write or append will always be created in the save directory. The same goes for other operations that involve writing to the filesystem, like mkdir.

Files that are opened for read will be looked for in the save directory, and then in the .love archive (in that order). So if a file with a certain filename (and path) exist in both the .love archive and the save folder, the one in the save directory takes precedence.

Note: All paths are relative to the .love archive and save directory. (except for the get*Directory() calls)

It is recommended to set your game's identity first in your conf.lua. You can set it with love.filesystem.setIdentity() as well.

Types

File Represents a file on the filesystem.
FileData Data representing the contents of a file.

Functions

love.filesystem.enumerate Returns all the files and subdirectories in the directory.
love.filesystem.exists Check whether a file or directory exists.
love.filesystem.getAppdataDirectory Returns the application data directory (could be the same as getUserDirectory)
love.filesystem.getLastModified Gets the last modification time of a file.
love.filesystem.getSaveDirectory Gets the full path to the designated save directory.
love.filesystem.getUserDirectory Returns the path of the user's directory
love.filesystem.getWorkingDirectory Gets the current working directory.
love.filesystem.init Initializes love.filesystem, will be called internally, so should not be used explictly.
love.filesystem.isDirectory Check whether something is a directory.
love.filesystem.isFile Check whether something is a file.
love.filesystem.lines Iterate over the lines in a file.
love.filesystem.load Load a file (but not run it)
love.filesystem.mkdir Creates a directory.
love.filesystem.newFile Creates a new File object.
love.filesystem.newFileData Creates a new FileData object.
love.filesystem.read Read the contents of a file
love.filesystem.remove Removes a file (or directory).
love.filesystem.setIdentity Sets the write directory for your game.
love.filesystem.setSource Sets the source of the game, where the code is present, can only be called once, done automatically.
love.filesystem.write Write data to a file

Enums

FileDecoder How to decode a given FileData.

See Also

Other Languages

Personal tools