allow mounting argument paths.

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
BorhilIan
Prole
Posts: 38
Joined: Wed Mar 15, 2017 6:46 am

allow mounting argument paths.

Post by BorhilIan » Thu Mar 28, 2019 11:41 am

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:

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

Re: allow mounting argument paths.

Post by zorg » Thu Mar 28, 2019 12:52 pm

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)
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.

User avatar
BorhilIan
Prole
Posts: 38
Joined: Wed Mar 15, 2017 6:46 am

Re: allow mounting argument paths.

Post by BorhilIan » Thu Mar 28, 2019 1:17 pm

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.

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

Re: allow mounting argument paths.

Post by zorg » Thu Mar 28, 2019 6:50 pm

If you are using löve, it already has the ffi.
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.

User avatar
BorhilIan
Prole
Posts: 38
Joined: Wed Mar 15, 2017 6:46 am

Re: allow mounting argument paths.

Post by BorhilIan » 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.

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

Re: allow mounting argument paths.

Post by zorg » Fri Mar 29, 2019 10:47 am

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)
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.

User avatar
pgimeno
Party member
Posts: 1944
Joined: Sun Oct 18, 2015 2:58 pm
Location: Valencia, ES

Re: allow mounting argument paths.

Post by pgimeno » Fri Mar 29, 2019 1:43 pm

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.

User avatar
Ref
Party member
Posts: 687
Joined: Wed May 02, 2012 11:05 pm

Re: allow mounting argument paths.

Post by Ref » Fri Mar 29, 2019 3:37 pm

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 ) )

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests