Merge pull request #1148 from celetor/master

获取网络zip文件里面的数据-增加从十六进制字符串中读取
pull/1155/head
kunfei 3 years ago committed by GitHub
commit 1fba49fa48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      app/src/main/java/io/legado/app/help/JsExtensions.kt

@ -314,14 +314,18 @@ interface JsExtensions {
/**
* 获取网络zip文件里面的数据
* @param url zip文件的链接
* @param url zip文件的链接或十六进制字符串
* @param path 所需获取文件在zip内的路径
* @return zip指定文件的数据
*/
fun getZipStringContent(url: String, path: String): String {
val bytes = runBlocking {
val bytes = if (url.startsWith("http://") || url.startsWith("https://")) {
runBlocking {
return@runBlocking okHttpClient.newCall { url(url) }.bytes()
}
} else {
StringUtils.hexStringToByte(url)
}
val bos = ByteArrayOutputStream()
val zis = ZipInputStream(ByteArrayInputStream(bytes))
@ -341,14 +345,18 @@ interface JsExtensions {
/**
* 获取网络zip文件里面的数据
* @param url zip文件的链接
* @param url zip文件的链接或十六进制字符串
* @param path 所需获取文件在zip内的路径
* @return zip指定文件的数据
*/
fun getZipByteArrayContent(url: String, path: String): ByteArray? {
val bytes = runBlocking {
val bytes = if (url.startsWith("http://") || url.startsWith("https://")) {
runBlocking {
return@runBlocking okHttpClient.newCall { url(url) }.bytes()
}
} else {
StringUtils.hexStringToByte(url)
}
val bos = ByteArrayOutputStream()
val zis = ZipInputStream(ByteArrayInputStream(bytes))

Loading…
Cancel
Save