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()
|
||||
for (child in children) {
|
||||
val newFile = File(source, child)
|
||||
if (Utils.needsStupidWritePermissions(context, destination.absolutePath)) {
|
||||
if (newFile.isDirectory) {
|
||||
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)
|
||||
copyStream(inputStream, out)
|
||||
}
|
||||
} else {
|
||||
copy(File(source, child), File(destination, child))
|
||||
copy(newFile, File(destination, child))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue