[RFC] pickFile function
Posted: Wed Jun 26, 2013 12:45 pm
Hi Everyone,
I have been using LOVE for the past week and so far I've been loving it!!
The problem
I am currently developing a game and I hope to create an in game editor at some point. It would be great if this editor can import images from the users documents and it would also be great if there could be a way to import/export maps
As we all know, for reasons I totally agree with, we can't access anything outside of the save directory.
A potential solution
One solution to this, without breaking LOVEs security model, is to implement a pickFile function
Fot those who don't know what a pickFile function is:
A pickFile function allows an application to open files from anywhere without exposing any users personal data to it. Its basically a function that you tell it what type of file you want and how you want to open it and it will call a callback with the File object when the file has been selected and opened. The application will never know what the filename was or where the file came from. Another potential advantage of this is it will allow other methods of getting a file such as taking a picture with a webcam to be seamlessly added in without the applications knowledge
This is how android opens files from other apps, it is part of their Intents system. A similar system is being implemented for the web called "Web Intents" which allows services such a facebook to import data from other services such as dropbox without them acctually seeing each other
Example
Asynchronous version:
Synchronous version:
Let me know what you think!
I have been using LOVE for the past week and so far I've been loving it!!
The problem
I am currently developing a game and I hope to create an in game editor at some point. It would be great if this editor can import images from the users documents and it would also be great if there could be a way to import/export maps
As we all know, for reasons I totally agree with, we can't access anything outside of the save directory.
A potential solution
One solution to this, without breaking LOVEs security model, is to implement a pickFile function
Fot those who don't know what a pickFile function is:
A pickFile function allows an application to open files from anywhere without exposing any users personal data to it. Its basically a function that you tell it what type of file you want and how you want to open it and it will call a callback with the File object when the file has been selected and opened. The application will never know what the filename was or where the file came from. Another potential advantage of this is it will allow other methods of getting a file such as taking a picture with a webcam to be seamlessly added in without the applications knowledge
This is how android opens files from other apps, it is part of their Intents system. A similar system is being implemented for the web called "Web Intents" which allows services such a facebook to import data from other services such as dropbox without them acctually seeing each other
Example
Asynchronous version:
Code: Select all
love.filesystem.pickFile(mimeTypes..., mode, callback)
Code: Select all
love.filesystem.pickFile("image/jpeg", "image/png", "r", function (file) image = love.graphics.newImage(file) file:close() end)
Code: Select all
file = love.filesystem.pickFile(mimeTypes..., mode)
Code: Select all
file = love.filesystem.pickFile("image/jpeg", "image/png", "r")
image = love.graphics.newImage(file)
file:close()