AndroidP7zip
AndroidP7zip copied to clipboard
How to compress multiple files?
How to compress multiple files?
This is command.
P7ZipApi.executeCommand(Command.getCompressCmd(list, outPath, type)) == ExitCode.EXIT_OK
type: String = "zip"
fun getCompressCmd(
fileInfos: List<FileSelectedEntity>,
outPath: String,
type: String
): String? {
val filePaths: ArrayList<String> = ArrayList()
for (i in fileInfos.indices) {
filePaths.add(fileInfos[i].path)
}
return getCompressCmd(filePaths, outPath, type)
}
fun getCompressCmd(filePaths: ArrayList<String>, outPath: String, type: String): String {
val command = StringBuilder(String.format("7z a -t%s '%s'", type, outPath))
for (i in 0 until filePaths.size) {
command.append(" '").append(filePaths[i]).append("'")
}
return command.toString()
}