love.filesystem.getRealDirectory
Available since LÖVE 0.9.2 |
This function is not supported in earlier versions. |
Gets the platform-specific absolute path of the directory containing a filepath.
This can be used to determine whether a file is inside the save directory or the game's source .love.
Contents
Function
Synopsis
realdir = love.filesystem.getRealDirectory( filepath )
Arguments
string filepath
- The filepath to get the directory of.
Returns
string realdir
- The platform-specific full path of the directory containing the filepath.
Notes
This function returns the directory containing the given file path, rather than file. For example, if the file screenshot1.png
exists in a directory called screenshots
in the game's save directory, love.filesystem.getRealDirectory("screenshots/screenshot1.png")
will return the same value as love.filesystem.getSaveDirectory.
Examples
-- Get all files in the "levels" folder.
-- There might be a "levels" folder in both the save directory and the game's source,
-- in which case this will get all files in both.
local filepaths = love.filesystem.getDirectoryItems("levels")
for i, filename in ipairs(filepaths) do
-- For each filename, check whether it's in the save directory or not.
local path = "levels/"..filename
if love.filesystem.getRealDirectory(path) == love.filesystem.getSaveDirectory() then
-- This file is in the save directory.
end
end
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info