Misunderstanding example in docs on Mount and Fuse

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
zell2002
Citizen
Posts: 56
Joined: Sun Feb 23, 2014 9:22 pm

Misunderstanding example in docs on Mount and Fuse

https://love2d.org/wiki/love.filesystem ... eDirectory

Im following the example here to mount a folder in the same fold at my mygame.exe
So to be clear:
mygame/
> mygame.exe
> myfolder/
> all dlls*

In my code I do the following:

Code: Select all

local maindir = "myfolder" -- "mygame" -- tried both game root folder and inner folder
local success = love.filesystem.mount(cwd, maindir)
if success then
msg = "yesfused"
else
msg = "nofused"
end

local files = love.filesystem.getDirectoryItems(maindir)
msg = msg .. "\file count : "..#files
for _, filename in ipairs(files) do
msg = msg .. "\n"..filename
end

Every time I try this (above) and run the exe, I only get the files in the root directory where my .exe is. I can't seem to read "myfolder"

What am I missing ?

The example in the documentation is a bit confusing as they mount "coolgame" but then say about the path being : "C:\Program Files\mycoolgame\"
Is "coolgame" a folder inside "mycoolgame" or is there a typo here?

zorg
Party member
Posts: 2529
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Misunderstanding example in docs on Mount and Fuse

Okay, so let's go back to the wiki's example code that you didn't use or look at, and allow me to edit it a smidge:

Code: Select all

if love.filesystem.isFused() then -- the game will be fused if it's an .exe already
local dir = love.filesystem.getSourceBaseDirectory() -- gets the real path of the directory (or folder, same thing) that contains the .exe
local success = love.filesystem.mount(dir, "coolgame") -- mounts the above directory into the virtual filesystem within the "folder" called coolgame

if success then
-- If it was successful, now you can refer to stuff next to your .exe as "coolgame/whatever"; if you have a directory called myfolder, you'd do
local files = love.filesystem.getDirectoryItems('coolgame/myfolder') -- and it'd return everything inside the myfolder directory that's next to your .exe
end
end

The example says that it mounted the real path that could be that C:/Program Files/mycoolgame onto the virtual filesystem that löve uses with the name coolgame; forget about the real filesystem, that was only used to mount the containing folder, you want to use the virtual filesystem stuff, since love.filesystem uses that as well. They are basically the same directory, one's just the name of the virtual mountpoint.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

grump
Party member
Posts: 535
Joined: Sat Jul 22, 2017 7:43 pm

Re: Misunderstanding example in docs on Mount and Fuse

AFAIK, you don't need to mount a folder that's inside the game directory.

Code: Select all

love.filesystem.getDirectoryItems('myfolder')
Works fine without mounting the folder.

zorg
Party member
Posts: 2529
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Misunderstanding example in docs on Mount and Fuse

grump wrote:
Sun Apr 22, 2018 1:43 pm
AFAIK, you don't need to mount a folder that's inside the game directory.

Code: Select all

love.filesystem.getDirectoryItems('myfolder')
Works fine without mounting the folder.
I don't think that works if it's fused since the game directory would be in the .love, which is fused to the love (or lovec) executable, hence the game dir would be inside the exe itself.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

grump
Party member
Posts: 535
Joined: Sat Jul 22, 2017 7:43 pm

Re: Misunderstanding example in docs on Mount and Fuse

zorg wrote:
Sun Apr 22, 2018 1:45 pm
I don't think that works if it's fused since the game directory would be in the .love, which is fused to the love (or lovec) executable, hence the game dir would be inside the exe itself.
Ah, right. In this case you need to do it like this:

Code: Select all

love.filesystem.mount(love.filesystem.getSourceBaseDirectory(), 'mygame')
local files = love.filesystem.getDirectoryItems('mygame/myfolder')
Edit: ...just as you wrote above, sigh. Sorry.

zorg
Party member
Posts: 2529
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Misunderstanding example in docs on Mount and Fuse

grump wrote:
Sun Apr 22, 2018 1:59 pm
zorg wrote:
Sun Apr 22, 2018 1:45 pm
I don't think that works if it's fused since the game directory would be in the .love, which is fused to the love (or lovec) executable, hence the game dir would be inside the exe itself.
Ah, right. In this case you need to do it like this:

Code: Select all

love.filesystem.mount(love.filesystem.getSourceBaseDirectory(), 'mygame')
local files = love.filesystem.getDirectoryItems('mygame/myfolder')
Edit: ...just as you wrote above, sigh. Sorry.
No worries, i guess we could write this off as an even exchange for my blunder in the color precision thread
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

Who is online

Users browsing this forum: Nelvin and 9 guests