Simple way for get dirs and files from user android filesystem

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
cristoferfb
Prole
Posts: 16
Joined: Wed May 15, 2019 12:41 am
Location: Valparaiso, Chile.

Simple way for get dirs and files from user android filesystem

Post by cristoferfb »

Hi, I want to access to all the user android filesystem (commonly /storage/emulated/0) I notice a function getDirectoryItems() but this not work:

Code: Select all

love.filesystem.getDirectoryItems("/storage/emulated/0/") 
(I have enable storage permissions)
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Simple way for get dirs and files from user android filesystem

Post by zorg »

Löve can't access anything other than the save directory and where main.lua is, whether the latter is a folder or inside a .love file (zip archive), and potentially the folder where the .love file is, if you can mount it (works on windows at least, idk about other OS-es)

There have been attempts at libraries that would allow arbitrary locations and absolute paths; you can try this, but not sure if it'll work on android or not: https://github.com/megagrump/nativefs
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.
cristoferfb
Prole
Posts: 16
Joined: Wed May 15, 2019 12:41 am
Location: Valparaiso, Chile.

Re: Simple way for get dirs and files from user android filesystem

Post by cristoferfb »

zorg wrote: Sun May 31, 2020 9:24 am Löve can't access anything other than the save directory and where main.lua is, whether the latter is a folder or inside a .love file (zip archive), and potentially the folder where the .love file is, if you can mount it (works on windows at least, idk about other OS-es)

There have been attempts at libraries that would allow arbitrary locations and absolute paths; you can try this, but not sure if it'll work on android or not: https://github.com/megagrump/nativefs
I am actually using the unix terminal of the android device.

Code: Select all

local dir = io.popen ("ls "..someDir)
io.input(dir)
I dont know if this is portable to any other android device I think yes. I will take a look to how works that library u mentioned.
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Simple way for get dirs and files from user android filesystem

Post by zorg »

lua io might fail with specific characters in paths & filenames; what i linked shouldn"t.
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
AuahDark
Party member
Posts: 107
Joined: Mon Oct 23, 2017 2:34 pm
Location: Indonesia
Contact:

Re: Simple way for get dirs and files from user android filesystem

Post by AuahDark »

cristoferfb wrote: Tue Jun 02, 2020 3:27 am I am actually using the unix terminal of the android device.

Code: Select all

local dir = io.popen ("ls "..someDir)
io.input(dir)
I dont know if this is portable to any other android device I think yes. I will take a look to how works that library u mentioned.
That works, but you have to request external storage permission. If the user denies it, then there's nothing you can do.
zorg wrote: Tue Jun 02, 2020 8:57 am lua io might fail with specific characters in paths & filenames; what i linked shouldn"t.
That only applies to Windows. io.open in Android (Linux) is UTF-8, so there's no problem with it.
Profile. Do you encounter crashes in LÖVE Android and wanna send me logcats? Please hit me up in LÖVE Discord and send the full logcat file!
Post Reply

Who is online

Users browsing this forum: rabbitboots and 95 guests