Page 1 of 1

allow mounting argument paths.

Posted: Thu Mar 28, 2019 11:41 am
by BorhilIan
You can already mount directory drop paths so why not argument paths to? Namely the love.load( args ) paths

My specific use case is I've written my own basic editor in love2D. Currently I drop folders on to my applications window but being able to do shortcuts would save alot of time. :?

Yes this editor I speak of will be openly available for all to use whet it's done. :nyu:

Re: allow mounting argument paths.

Posted: Thu Mar 28, 2019 12:52 pm
by zorg
What exactly do you mean? I'm having a bit of trouble getting what you want exactly.

If you mean like you want to mount whatever is passed as command-line arguments to your project, then yeah, that's not supported by löve by itself.

I do have a library you could try out that auto-mounts more or less the whole filesystem... or just use part of it to overwrite the mount function so that it never checks the paths like how it does now (file/directorydropped sidesteps that, but they do their own checks)

Re: allow mounting argument paths.

Posted: Thu Mar 28, 2019 1:17 pm
by BorhilIan
Seems your library require something called ffi. Which I have no idea how to get.

Basically just saying make it so that any folders passed in the command-line arguments could be mounted just like the drop directory. would just be a nice generally useful feature to have.

In my project I'm currently using the drop method but I use IO library to actually write new data. The only reason I mount it is so I can use images with the newImage function though I could just use IO to read the raw and pass that.

Re: allow mounting argument paths.

Posted: Thu Mar 28, 2019 6:50 pm
by zorg
If you are using löve, it already has the ffi.

Re: allow mounting argument paths.

Posted: Thu Mar 28, 2019 7:10 pm
by BorhilIan
That's definitely good to know, didn't realize LuaJit was more than speed. :awesome:

Does your library also allow writing to basically any folder or just mounting? If its just mounting that is still useful since I can write changes with IO then remount the folder.

Re: allow mounting argument paths.

Posted: Fri Mar 29, 2019 10:47 am
by zorg
BorhilIan wrote: Thu Mar 28, 2019 7:10 pm That's definitely good to know, didn't realize LuaJit was more than speed. :awesome:

Does your library also allow writing to basically any folder or just mounting? If its just mounting that is still useful since I can write changes with IO then remount the folder.
My lib already mounts the root of your filesystem (and all lettered drives on windows, given that they do exist as drives), hence why i said that you may just want to take the redefined love.filesystem.mount method and use only that for your own purposes.

As for writing, it does not yet allow it, because i would want to circumvent the one write folder limitation of PhysFS, and the only way i could do that is if i used lua apis for writing... which may or may not work depending on OS and character encodings; i'll need to test tons of things to be honest. (And i also don't want to use external non-lua libs like luafilesystem)

Re: allow mounting argument paths.

Posted: Fri Mar 29, 2019 1:43 pm
by pgimeno
There's also https://github.com/linux-man/lovefs which is an alternative API. You lose some advantages of love.filesystem. but gain a good bunch of new functions.

Re: allow mounting argument paths.

Posted: Fri Mar 29, 2019 3:37 pm
by Ref
For just playing around on windows I use the simple mount function to get around Love's file restrictions.

Code: Select all

mount = function( name )
	local ffi = require( 'ffi' )
	local lv	= ffi.load( 'love' )
	ffi.cdef[[ int PHYSFS_mount(const char *newDir, const char *mountPoint, int appendToPath); ]];
	ffi.cdef[[ int PHYSFS_setWriteDir(const char *newDir); ]]
	local file	= name:match( "^.+/(.+)$" )			-- filename
	local path	= string.sub( name, 1, -(#file+1) )	-- path without filename
	lv.PHYSFS_setWriteDir( path )
	lv.PHYSFS_mount( path, nil, 0 )
	return file
	end
-- ***** Load/Save from Anywhere on Computer *****
-- To use, wrap 'filename' with 'mount'.
-- for filename = 'D:/Scripts/Love/test.png'
-- Load Example: love.graphics.newImage( mount( filename ) )
-- Save Example: imagedata:encode('png', mount( filename ) )
-- for dir = 'D:/Scripts/Love'
-- Files in Directory: files = love.filesystem.getDirectoryItems( mount( dir ) )
-- Create Directory: love.filesystem.createDirectory( mount( savedir ) )