I’m using expo v51 react-native, expo-file-system package. So, I want to get the information from files recursively inside a given directory, to get all the paths of files inside it and return:
const getContentsOfFolder = async (source: string): Promise<MusicFile[]> => {
const musicList: MusicFile[] = [];
(await FileSystem.StorageAccessFramework.readDirectoryAsync(source)).map(
async (fileUri: string) => {
const musicFileInfo = await FileSystem.getInfoAsync(fileUri);
if (musicFileInfo.isDirectory) {
const dirList = await getContentsOfFolder(musicFileInfo.uri);
console.log("Aqui está a dirList: " + dirList);
musicList.concat(dirList);
}
musicList.push({
uri: musicFileInfo.uri,
title: musicFileInfo.uri,
});
},
);
return musicList;
};
But when I run this function, FileSystem.getInfoAsync runs on all files, but when it gets to directories, it throws this error:
Possible unhandled promise rejection (id: 0):
Error: Call to function 'ExponentFileSystem.getInfoAsync' has been rejected.
-> Caused by java.io.IOException: Function not implemented
I’ve read through the docs several times, but I’m all out of ideas.
I’ve tried looking for alternative methods to do dynamic recursive search through files, but haven’t found anything useful yet. I’ve logged all the results of the function, and when I run this function, files return as expected, it’s just the directories that throw errors.
Pedro Vidal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.