W3cubDocs

/LÖVE

love.filesystem.getSourceBaseDirectory

Available since LÖVE 0.9.0
This function is not supported in earlier versions.

Returns the full path to the directory containing the .love file. If the game is fused to the LÖVE executable, then the directory containing the executable is returned.

If love.filesystem.isFused is true, the path returned by this function can be passed to love.filesystem.mount, which will make the directory containing the main game (e.g. C:\Program Files\coolgame\) readable by love.filesystem.

Function

Synopsis

path = love.filesystem.getSourceBaseDirectory( )

Arguments

None.

Returns

string path
The full platform-dependent path of the directory containing the .love file.

Examples

read files in the same folder as the game's .exe file

if love.filesystem.isFused() then
    local dir = love.filesystem.getSourceBaseDirectory()
    local success = love.filesystem.mount(dir, "coolgame")
 
    if success then
        -- If the game is fused and it's located in C:\Program Files\mycoolgame\,
        -- then we can now load files from that path.
        coolimage = love.graphics.newImage("coolgame/coolimage.png")
    end
end
 
function love.draw()
    if coolimage then
        love.graphics.draw(coolimage, 0, 0)
    end
end

See Also

© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.filesystem.getSourceBaseDirectory