fix crash on adding through image virtual directory
https://github.com/Anthonyy232/Paperize/issues/374
This commit is contained in:
1 parent
ba7d29990c
commit
40417b99b1
1 file changed
+2
-16
@@ -659,28 +659,14 @@ fun isDirectory(context: Context, uriString: String?): Boolean {
|
||||
* Compress a string
|
||||
*/
|
||||
fun String.compress(prefixToRemove: String, charset: Charset = Charsets.UTF_8): String {
|
||||
val modifiedInput = if (this.startsWith(prefixToRemove)) {
|
||||
this.substring(prefixToRemove.length)
|
||||
} else { this }
|
||||
ByteArrayOutputStream().use { byteStream ->
|
||||
DeflaterOutputStream(byteStream).use { deflaterStream ->
|
||||
deflaterStream.write(modifiedInput.toByteArray(charset))
|
||||
}
|
||||
return Base64.encodeToString(byteStream.toByteArray(), Base64.NO_WRAP)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Decompress a string
|
||||
*/
|
||||
fun String.decompress(prefixToAdd: String, charset: Charset = Charsets.UTF_8): String {
|
||||
val compressedData = Base64.decode(this, Base64.NO_WRAP)
|
||||
ByteArrayInputStream(compressedData).use { byteStream ->
|
||||
InflaterInputStream(byteStream).use { inflaterStream ->
|
||||
val decompressedBytes = inflaterStream.readBytes()
|
||||
return prefixToAdd + String(decompressedBytes, charset)
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user