fix recursive copying
This commit is contained in:
parent
2422b0fd53
commit
5b79b025ce
|
@ -54,15 +54,20 @@ class CopyTask(listener: CopyTask.CopyListener, val context: Context) : AsyncTas
|
||||||
|
|
||||||
val children = source.list()
|
val children = source.list()
|
||||||
for (child in children) {
|
for (child in children) {
|
||||||
|
val newFile = File(source, child)
|
||||||
if (Utils.needsStupidWritePermissions(context, destination.absolutePath)) {
|
if (Utils.needsStupidWritePermissions(context, destination.absolutePath)) {
|
||||||
var document = Utils.getFileDocument(context, destination.absolutePath)
|
if (newFile.isDirectory) {
|
||||||
document = document.createFile("", child)
|
copyDirectory(newFile, File(destination, child))
|
||||||
|
} else {
|
||||||
|
var document = Utils.getFileDocument(context, destination.absolutePath)
|
||||||
|
document = document.createFile("", child)
|
||||||
|
|
||||||
val inputStream = FileInputStream(File(source, child))
|
val inputStream = FileInputStream(newFile)
|
||||||
val out = context.contentResolver.openOutputStream(document.uri)
|
val out = context.contentResolver.openOutputStream(document.uri)
|
||||||
copyStream(inputStream, out)
|
copyStream(inputStream, out)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
copy(File(source, child), File(destination, child))
|
copy(newFile, File(destination, child))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue