Module
love.filesystem
This module provides access to Files in two places, and two places only:
  • The root folder of the .love-file. (Alternatively a directory).
  • The root folder of the save directory.
Each game is granted a single diretory on the user system where files can be saved. Full access to normal file I/O is no longer present due to security concerns. The directories will typically be something like:
  • C:\Documents and Settings\user\Application Data\LOVE\game
  • /home/user/.love/game
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 game root folder, and then the save directory (in that order). So if a file with a certain filename (and path) exist in both the .love-file and the save folder, the one in the .love-file takes precedence.

Types
File A file that can be read from or written to.
Functions
newFile( filename ) Constructs a File with the given filename.
newFile( filename, mode ) Constructs a File with the given filename.
getWorkingDirectory( ) Gets the current working directory.
getSaveDirectory( ) Gets the full path to the designated save directory.
exists( filename ) Check whether a file exists.
isDirectory( dirname ) Check whether something is a directory.
isFile( filename ) Check whether something is a file.
mkdir( dirname ) Creates a directory.
remove( filename ) Removes a file (or directory).
open( file ) Opens the file for reading/writing (depending on its mode).
close( file ) Closes the file.
read( file ) Reads bytes from an opened File.
read( file, bytes ) Reads bytes from an opened File.
read( filename ) Quick read using filename.
read( filename, bytes ) Quick read using filename.
write( file, data ) Writes bytes to an opened File.
write( filename, data ) Quick write using filename.
lines( file ) Iterate the lines in a File.
lines( filename ) Iterate the lines in a File.
eof( file ) Check if end-of-file is reached.
tell( file ) Gets the current position in a file.
seek( file, pos ) Seek to a position within a file.
enumerate( dir ) Gets a list of files in the given directory.
require( filename ) Includes and runs a Lua file (once).
include( filename ) Includes and runs a Lua file.
load( filename ) Loads a Lua-file without running it.
Copyright © 2006-2008 LÖVE Development Team.