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.
realdir = love.filesystem.getRealDirectory( filepath )
string filepathstring realdirThis 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.
-- 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
© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.filesystem.getRealDirectory