Page 1 of 1

[QUESTION] Access contents of dropped folder?

Posted: Fri Oct 26, 2018 12:03 am
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?

Re: [QUESTION] Access contents of dropped folder?

Posted: Fri Oct 26, 2018 12:14 am
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.

Re: [QUESTION] Access contents of dropped folder?

Posted: Fri Oct 26, 2018 12:49 am
by BorhilIan
I remember trying that once before to no avail, however it worked this time so thanks.

Re: [QUESTION] Access contents of dropped folder?

Posted: Fri Oct 26, 2018 1:38 am
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.

Re: [QUESTION] Access contents of dropped folder?

Posted: Fri Oct 26, 2018 9:08 am
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.

Re: [QUESTION] Access contents of dropped folder?

Posted: Fri Oct 26, 2018 10:06 am
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

Re: [QUESTION] Access contents of dropped folder?

Posted: Fri Oct 26, 2018 10:10 am
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. :)