优化
This commit is contained in:
@@ -12,4 +12,10 @@ class WebDavFile(
|
|||||||
val size: Long,
|
val size: Long,
|
||||||
val contentType: String,
|
val contentType: String,
|
||||||
val lastModify: Long
|
val lastModify: Long
|
||||||
) : WebDav(urlStr, authorization)
|
) : WebDav(urlStr, authorization) {
|
||||||
|
|
||||||
|
val isDir by lazy {
|
||||||
|
contentType == "httpd/unix-directory"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -41,21 +41,15 @@ object RemoteBookWebDav : RemoteBookManager() {
|
|||||||
val remoteBooks = mutableListOf<RemoteBook>()
|
val remoteBooks = mutableListOf<RemoteBook>()
|
||||||
AppWebDav.authorization?.let {
|
AppWebDav.authorization?.let {
|
||||||
//读取文件列表
|
//读取文件列表
|
||||||
var remoteWebDavFileList: List<WebDavFile>? = null
|
val remoteWebDavFileList: List<WebDavFile> = WebDav(remoteBookUrl, it).listFiles()
|
||||||
kotlin.runCatching {
|
|
||||||
remoteWebDavFileList = WebDav(remoteBookUrl, it).listFiles()
|
|
||||||
}
|
|
||||||
//逆序文件排序
|
|
||||||
remoteWebDavFileList = remoteWebDavFileList!!.reversed()
|
|
||||||
//转化远程文件信息到本地对象
|
//转化远程文件信息到本地对象
|
||||||
remoteWebDavFileList!!.forEach { webDavFile ->
|
remoteWebDavFileList.forEach { webDavFile ->
|
||||||
var webDavFileName = webDavFile.displayName
|
var webDavFileName = webDavFile.displayName
|
||||||
var webDavUrlName = "${remoteBookUrl}${File.separator}${webDavFile.displayName}"
|
var webDavUrlName = "${remoteBookUrl}${File.separator}${webDavFile.displayName}"
|
||||||
webDavFileName = URLDecoder.decode(webDavFileName,"utf-8")
|
webDavFileName = URLDecoder.decode(webDavFileName, "utf-8")
|
||||||
webDavUrlName = URLDecoder.decode(webDavUrlName,"utf-8")
|
webDavUrlName = URLDecoder.decode(webDavUrlName, "utf-8")
|
||||||
// 转码
|
|
||||||
//val trueFileName = String(webDavFileName.toByteArray(Charset.forName("GBK")), Charset.forName("UTF-8"))
|
webDavFile.isDir
|
||||||
//val trueUrlName = String(webDavUrlName.toByteArray(Charset.forName("GBK")), Charset.forName("UTF-8"))
|
|
||||||
|
|
||||||
//分割后缀
|
//分割后缀
|
||||||
val fileExtension = webDavFileName.substringAfterLast(".")
|
val fileExtension = webDavFileName.substringAfterLast(".")
|
||||||
|
|||||||
Reference in New Issue
Block a user