[QUESTION] Access contents of dropped folder?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
BorhilIan
Prole
Posts: 38
Joined: Wed Mar 15, 2017 6:46 am

[QUESTION] Access contents of dropped folder?

Post by BorhilIan »

If I drop a folder onto my packed exe how do i access its contents. I don't seem to be able to mount it or read the files in said folder directly. Is there a way to copy the folder into the identity folder when dropped on the exe?
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: [QUESTION] Access contents of dropped folder?

Post by zorg »

A few assumptions;
Did you try using love.directorydropped?
Then inside that callback, you can use love.filesystem.mount to mount it to some virtual path of your choosing.
Me and my stuff :3True 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.
BorhilIan
Prole
Posts: 38
Joined: Wed Mar 15, 2017 6:46 am

Re: [QUESTION] Access contents of dropped folder?

Post by BorhilIan »

I remember trying that once before to no avail, however it worked this time so thanks.
BorhilIan
Prole
Posts: 38
Joined: Wed Mar 15, 2017 6:46 am

Re: [QUESTION] Access contents of dropped folder?

Post by BorhilIan »

It's a shame you cant also mount argument paths, like dragging folder onto the exe. If you know of a solution for that it would be much appreciated. I'll just use the drag n' drop method for now.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: [QUESTION] Access contents of dropped folder?

Post by grump »

You can access command line arguments from the global arg table:

Code: Select all

local folder = arg[1] -- get the first argument
You can't mount the directory though if it's outside the normally allowed locations. Use this to make that work too:

Code: Select all

local function mount(path)
	local C = ffi.os == 'Windows' and ffi.load('love') or ffi.C
	ffi.cdef('int PHYSFS_mount(const char *newDir, const char *mountPoint, int appendToPath);')
	return C.PHYSFS_mount(path, 'thedamnfolder', 0) ~= 0
end
If that function returns true, the folder contents can be accessed with love.filesystem by using 'thedamnfolder' as the path. If it returns false, something went wrong. To find out what went wrong is left as an excercise for the reader.
Last edited by grump on Sat Oct 27, 2018 3:54 am, edited 1 time in total.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: [QUESTION] Access contents of dropped folder?

Post by zorg »

grump wrote: Fri Oct 26, 2018 9:08 amTo find out what went wrong is left as an excercise for the reader.
Or alternatively, you might wait for a few eons util i release my "easy handling" lib that can read from/write to anywhere :P
Me and my stuff :3True 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: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: [QUESTION] Access contents of dropped folder?

Post by grump »

zorg wrote: Fri Oct 26, 2018 10:06 am Or alternatively, you might wait for a few eons util i release my "easy handling" lib that can read from/write to anywhere :P
You wrote that a few eons ago in that other thread :awesome: Still waiting. :)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests