mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2025-12-16 12:08:49 +00:00
Added additional logging for Android rename/move
This commit is contained in:
parent
ec9a782aab
commit
7498682b3c
@ -683,6 +683,9 @@ object NativeLibrary {
|
|||||||
try {
|
try {
|
||||||
CitraApplication.documentsTree.renameFile(path, destinationFilename)
|
CitraApplication.documentsTree.renameFile(path, destinationFilename)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
if (e.message != null) {
|
||||||
|
Log.error(e.message!!)
|
||||||
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -696,6 +699,9 @@ object NativeLibrary {
|
|||||||
try {
|
try {
|
||||||
CitraApplication.documentsTree.moveFile(filename, sourceDirPath, destinationDirPath)
|
CitraApplication.documentsTree.moveFile(filename, sourceDirPath, destinationDirPath)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
if (e.message != null) {
|
||||||
|
Log.error(e.message!!)
|
||||||
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -192,7 +192,9 @@ class DocumentsTree {
|
|||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun renameFile(filepath: String, destinationFilename: String): Boolean {
|
fun renameFile(filepath: String, destinationFilename: String): Boolean {
|
||||||
val node = resolvePath(filepath) ?: return false
|
val node = resolvePath(filepath) ?: run {
|
||||||
|
error("[DocumentsTree]: Failed to resolve path during rename: $filepath")
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
val filename = URLDecoder.decode(destinationFilename, FileUtil.DECODE_METHOD)
|
val filename = URLDecoder.decode(destinationFilename, FileUtil.DECODE_METHOD)
|
||||||
val newUri = DocumentsContract.renameDocument(context.contentResolver, node.uri!!, filename)
|
val newUri = DocumentsContract.renameDocument(context.contentResolver, node.uri!!, filename)
|
||||||
@ -205,9 +207,16 @@ class DocumentsTree {
|
|||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun moveFile(filename: String, sourceDirPath: String, destDirPath: String): Boolean {
|
fun moveFile(filename: String, sourceDirPath: String, destDirPath: String): Boolean {
|
||||||
val sourceFileNode = resolvePath(sourceDirPath + "/" + filename) ?: return false
|
val resolutionErrorMessage = "[DocumentsTree]: Failed to resolve path during move: "
|
||||||
val sourceDirNode = resolvePath(sourceDirPath) ?: return false
|
val sourceFileNode = resolvePath(sourceDirPath + "/" + filename) ?: run {
|
||||||
val destDirNode = resolvePath(destDirPath) ?: return false
|
error(resolutionErrorMessage + (sourceDirPath + "/" + filename))
|
||||||
|
}
|
||||||
|
val sourceDirNode = resolvePath(sourceDirPath) ?: run {
|
||||||
|
error(resolutionErrorMessage + sourceDirPath)
|
||||||
|
}
|
||||||
|
val destDirNode = resolvePath(destDirPath) ?: run {
|
||||||
|
error(resolutionErrorMessage + destDirPath)
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
val newUri = DocumentsContract.moveDocument(context.contentResolver, sourceFileNode.uri!!, sourceDirNode.uri!!, destDirNode.uri!!)
|
val newUri = DocumentsContract.moveDocument(context.contentResolver, sourceFileNode.uri!!, sourceDirNode.uri!!, destDirNode.uri!!)
|
||||||
sourceFileNode.rename(filename, newUri)
|
sourceFileNode.rename(filename, newUri)
|
||||||
@ -229,7 +238,7 @@ class DocumentsTree {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
error("[DocumentsTree]: Cannot rename file, error: " + e.message)
|
error("[DocumentsTree]: Cannot delete file, error: " + e.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user