JohnSundell / Files

A nicer way to handle files & folders in Swift
MIT License
2.53k stars 182 forks source link

Subfolder on iOS is returning empty while on Mac returns content #121

Closed NSCabezon closed 3 years ago

NSCabezon commented 4 years ago

Hi!

I have the following code which on iOS is returning as if the specified folder has no subfolders (which it does). While on macOS it does work, any idea why?

func listFolders(at path: String) -> [Folder] {
    do {
        let originFolder = try Folder(path: path)
        var folders = [Folder]()
        originFolder.subfolders.forEach { folder in
            folders.append(folder)
        }
        return folders
    } catch {
        print(error)
    }
    return []
}

PS: I'm using an external SSD in both cases

NSCabezon commented 3 years ago

It was a permission problem, solved by adding url.startAccessingSecurityScopedResource() before trying to access files