Use patched dmg2img to display size of DMG partitions
This commit is contained in:
parent
e81f12af6f
commit
fd10548035
1 changed files with 11 additions and 3 deletions
|
@ -10,13 +10,14 @@ import eu.depau.etchdroid.utils.Partition
|
||||||
import eu.depau.etchdroid.utils.PartitionBuilder
|
import eu.depau.etchdroid.utils.PartitionBuilder
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
private val partRegex = Regex("partition (\\d+): (.*) \\((.+) : \\d+\\)")
|
val SECTOR_SIZE = 512
|
||||||
|
private val partRegex = Regex("partition (\\d+): begin=(\\d+), size=(\\d+), decoded=(\\d+), firstsector=(\\d+), sectorcount=(\\d+), blocksruncount=(\\d+)\\s+(.*) \\((.+) : \\d+\\)", RegexOption.MULTILINE)
|
||||||
|
|
||||||
private fun readPartitionTable(dmg2img: File, libDir: String, file: File): Pair<PartitionTableType?, List<Partition>?> {
|
private fun readPartitionTable(dmg2img: File, libDir: String, file: File): Pair<PartitionTableType?, List<Partition>?> {
|
||||||
val pt = ArrayList<Partition>()
|
val pt = ArrayList<Partition>()
|
||||||
var ptType: PartitionTableType? = null
|
var ptType: PartitionTableType? = null
|
||||||
|
|
||||||
val pb = ProcessBuilder(dmg2img.path, "-l", file.path)
|
val pb = ProcessBuilder(dmg2img.path, "-v", "-l", file.path)
|
||||||
pb.environment()["LD_LIBRARY_PATH"] = libDir
|
pb.environment()["LD_LIBRARY_PATH"] = libDir
|
||||||
pb.redirectErrorStream(true)
|
pb.redirectErrorStream(true)
|
||||||
|
|
||||||
|
@ -27,10 +28,17 @@ private fun readPartitionTable(dmg2img: File, libDir: String, file: File): Pair<
|
||||||
val matches = partRegex.findAll(out)
|
val matches = partRegex.findAll(out)
|
||||||
|
|
||||||
matchloop@ for (m in matches) {
|
matchloop@ for (m in matches) {
|
||||||
val (number, label, type) = m.destructured
|
val (
|
||||||
|
number, begin, size,
|
||||||
|
decoded, firstsector,
|
||||||
|
sectorcount, blocksruncount,
|
||||||
|
label, type
|
||||||
|
) = m.destructured
|
||||||
|
|
||||||
val pb = PartitionBuilder()
|
val pb = PartitionBuilder()
|
||||||
|
|
||||||
pb.number = number.toInt()
|
pb.number = number.toInt()
|
||||||
|
pb.size = SECTOR_SIZE * sectorcount.toLong()
|
||||||
|
|
||||||
if (label.isNotEmpty())
|
if (label.isNotEmpty())
|
||||||
pb.fsLabel = label
|
pb.fsLabel = label
|
||||||
|
|
Loading…
Reference in a new issue