You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Added appending installers to modules
This commit is contained in:
committed by
John Wu
parent
967bdeae7b
commit
0785945635
@@ -10,16 +10,30 @@ inline fun ResponseBody.writeToCachedFile(
|
||||
context: Context,
|
||||
fileName: String,
|
||||
progress: (Long) -> Unit = {}
|
||||
): File {
|
||||
val file = File(context.cacheDir, fileName)
|
||||
withStreams(byteStream(), file.outputStream()) { inStream, outStream ->
|
||||
): File = byteStream().writeToCachedFile(context, fileName, progress)
|
||||
|
||||
inline fun InputStream.writeToCachedFile(
|
||||
context: Context,
|
||||
fileName: String,
|
||||
progress: (Long) -> Unit = {}
|
||||
) = context.cachedFile(fileName).apply {
|
||||
writeToFile(this, progress)
|
||||
}
|
||||
|
||||
inline fun InputStream.writeToFile(file: File, progress: (Long) -> Unit = {}) = file.apply {
|
||||
writeTo(file.outputStream(), progress)
|
||||
}
|
||||
|
||||
inline fun InputStream.writeTo(output: OutputStream, progress: (Long) -> Unit = {}) {
|
||||
withStreams(this, output) { inStream, outStream ->
|
||||
inStream.copyToWithProgress(outStream, progress)
|
||||
}
|
||||
return file
|
||||
}
|
||||
|
||||
fun ResponseBody.writeToString() = string()
|
||||
|
||||
fun Context.cachedFile(name: String) = File(cacheDir, name)
|
||||
|
||||
inline fun InputStream.copyToWithProgress(
|
||||
out: OutputStream,
|
||||
progressEmitter: (Long) -> Unit,
|
||||
|
||||
Reference in New Issue
Block a user