Difference between revisions of "love.filesystem"
m (1 revision: Importing from potato (again).) |
m |
||
Line 1: | Line 1: | ||
− | |||
Provides an interface to the user's filesystem. | Provides an interface to the user's filesystem. | ||
This module provides access to Files in two places, and two places only: | 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 .love-file. (Alternatively a directory). | ||
* The root folder of the write directory. | * The root folder of the write directory. | ||
− | |||
Each game is granted a single directory on the system where files can be saved through love.filesystem. These directories will typically be something like: | Each game is granted a single directory on the system where files can be saved through love.filesystem. These directories will typically be something like: | ||
− | |||
* C:\Documents and Settings\user\Application Data\Love\game or %appdata%\Love | * C:\Documents and Settings\user\Application Data\Love\game or %appdata%\Love | ||
* /home/user/.love/game or ~/.love/game | * /home/user/.love/game or ~/.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 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. | ||
Line 20: | Line 15: | ||
Files that are opened for read will be looked for the game root folder, and then in 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. | Files that are opened for read will be looked for the game root folder, and then in 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. | ||
− | Currently, you have to set your game's identity first with [[love.filesystem.setIdentity]] | + | Currently, you have to set your game's identity first with [[love.filesystem.setIdentity]]. |
== Types == | == Types == | ||
{{#ask: [[Category:Types]] [[parent::love.filesystem]] | {{#ask: [[Category:Types]] [[parent::love.filesystem]] |
Revision as of 17:10, 14 February 2010
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-file. (Alternatively a directory).
- The root folder of the write directory.
Each game is granted a single directory on the system where files can be saved through love.filesystem. These directories will typically be something like:
- C:\Documents and Settings\user\Application Data\Love\game or %appdata%\Love
- /home/user/.love/game or ~/.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 the game root folder, and then in 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.
Currently, you have to set your game's identity first with love.filesystem.setIdentity.
Types
DroppedFile | Represents a file dropped from the window. |
File | Represents a file on the filesystem. |
FileData | Data representing the contents of a file. |
Functions
love.filesystem.append | Append data to an existing file. |
love.filesystem.areSymlinksEnabled | Gets whether love.filesystem follows symbolic links. |
love.filesystem.createDirectory | Creates a directory. |
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.getCRequirePath | Gets the filesystem paths that will be searched for c libraries when require is called. |
love.filesystem.getDirectoryItems | Returns all the files and subdirectories in the directory. |
love.filesystem.getIdentity | Gets the write directory name for your game. |
love.filesystem.getInfo | Gets information about the specified file or directory. |
love.filesystem.getLastModified | Gets the last modification time of a file. |
love.filesystem.getRealDirectory | Gets the absolute path of the directory containing a filepath. |
love.filesystem.getRequirePath | Gets the filesystem paths that will be searched when require is called. |
love.filesystem.getSaveDirectory | Gets the full path to the designated save directory. |
love.filesystem.getSize | Gets the size in bytes of a file. |
love.filesystem.getSource | Returns the full path to the .love file or directory. |
love.filesystem.getSourceBaseDirectory | Returns the full path to the directory containing the .love file. |
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 explicitly. |
love.filesystem.isDirectory | Check whether something is a directory. |
love.filesystem.isFile | Check whether something is a file. |
love.filesystem.isFused | Gets whether the game is in fused mode or not. |
love.filesystem.isSymlink | Gets whether a filepath is actually a symbolic link. |
love.filesystem.lines | Iterate over the lines in a file. |
love.filesystem.load | Loads a Lua file (but does not run it). |
love.filesystem.mkdir | Creates a directory. |
love.filesystem.mount | Mounts a zip file or folder in the game's save directory for reading. |
love.filesystem.mountFullPath | Mounts a full platform-dependent path to a zip file or folder for reading or writing in love.filesystem. |
love.filesystem.newFile | Creates a new File object. |
love.filesystem.newFileData | Creates a new FileData object from a file on disk, or from a string in memory. |
love.filesystem.openFile | Opens a new File object, which represents an existing or new file on disk. |
love.filesystem.read | Read the contents of a file. |
love.filesystem.remove | Removes a file (or directory). |
love.filesystem.setCRequirePath | Sets the filesystem paths that will be searched for c libraries when require is called. |
love.filesystem.setIdentity | Sets the write directory for your game. |
love.filesystem.setRequirePath | Sets the filesystem paths that will be searched when require is called. |
love.filesystem.setSource | Sets the source of the game, where the code is present. Used internally. |
love.filesystem.setSymlinksEnabled | Sets whether love.filesystem follows symbolic links. |
love.filesystem.unmount | Unmounts a zip file or folder previously mounted with love.filesystem.mount. |
love.filesystem.unmountFullPath | Unmounts a zip file or folder previously mounted with love.filesystem.mountFullPath. |
love.filesystem.write | Write data to a file. |