small tweak to file document obtaining

This commit is contained in:
tibbi 2017-02-17 19:16:35 +01:00
parent cf6b707250
commit dcb2575ee9

View file

@ -95,7 +95,10 @@ fun Context.isAStorageRootFolder(path: String): Boolean {
}
fun Context.getFileDocument(path: String, treeUri: String): DocumentFile {
val relativePath = path.substring(getSDCardPath().length + 1)
var relativePath = path.substring(getSDCardPath().length)
if (relativePath.startsWith(File.separator))
relativePath = relativePath.substring(1)
var document = DocumentFile.fromTreeUri(this, Uri.parse(treeUri))
val parts = relativePath.split("/")
for (part in parts) {