kdmg is a Kotlin library to unpack DMG files (disk images often used for macOS software distribution).
This repository includes the library code in the lib module,
and a command-line application to perform some basic tasks in the app module.
The library will be published to Maven Central, the installation documentation will be available later.
Current usage can be illustrated by the following snippet:
import kotlin.io.path.Path
import me.fornever.kdmg.Dmg
val path = Path("myFile.dmg")
// Read the DMG file table:
val dmg = Dmg.read(path)
// Enumerate the BLKX table descriptors:
for (entry in dmg.descriptors) {
println("name: ${entry.name}, table: ${entry.table}")
}
// Find and unpack the Apple_HFS image:
val hfsDescriptor = dmg.descriptors.single { it.name.contains("Apple_HFS") }
val hfsPath = Path("image.hfs")
dmg.unpackBlkx(hfsDescriptor.table, hfsPath)Use the following shell command to run the application:
$ ./gradlew :app:run --args="enter the real args here"Where args could be:
dmg <path to a .dmg file>- will find a HFS+ image in the file, unpack and save it to the pathapp/build/image.hfs.
- Technical Note TN1150: HFS Plus Volume Format (Apple)
- Demystifying the DMG File Format (Jonathan Levin)
The project is distributed under the terms of the Apache 2.0 license.
The license indication in the project's sources is compliant with the REUSE specification v3.3.