Implement robust file downloading, uploading and opening

Signed-off-by: denis0001-dev <denis0001.dev@ya.ru>
This commit is contained in:
2026-05-29 20:23:52 +03:00
Unverified
parent 76645e2633
commit 70a9f8635e
104 changed files with 5767 additions and 881 deletions
@@ -12,6 +12,17 @@ internal actual fun expectWriteBytes(path: String, bytes: ByteArray) {
file.writeBytes(bytes)
}
internal actual fun expectAppendBytes(path: String, bytes: ByteArray) {
val file = File(path)
file.parentFile?.mkdirs()
file.appendBytes(bytes)
}
internal actual fun expectFileSize(path: String): Long {
val file = File(path)
return if (file.isFile) file.length() else 0L
}
internal actual fun expectDelete(path: String) {
File(path).delete()
}
@@ -26,6 +37,12 @@ internal actual fun expectDeleteFilesWithPrefix(dirPath: String, namePrefix: Str
}
}
internal actual fun expectListFileNamesInDirectory(dirPath: String): List<String> {
val dir = File(dirPath)
if (!dir.isDirectory) return emptyList()
return dir.listFiles()?.map { it.name } ?: emptyList()
}
internal actual fun expectGetAppCacheDirectory(): String =
UtilsLibrary.context.cacheDir.absolutePath