added seekDmgPartition() to pick partitions in already opened DMG

This commit is contained in:
Eugene Homyakov 2012-04-06 16:10:05 +04:00
Родитель bc434eb65e
Коммит 756153e984
2 изменённых файлов: 15 добавлений и 8 удалений

Просмотреть файл

@ -76,7 +76,7 @@ static void cacheRun(DMG* dmg, BLKXTable* blkx, int run) {
case BLOCK_ZEROES:
break;
case BLOCK_BZIP2:
ASSERT(0, "bzip2 decompressions is not supported yet");
ASSERT(0, "bzip2-compressed images are not supported yet");
break;
default:
fprintf(stderr, "error: unsupported block type %08x", blkx->runs[run].type);
@ -144,6 +144,7 @@ static int dmgFileRead(io_func* io, off_t location, size_t size, void *buffer) {
static int dmgFileWrite(io_func* io, off_t location, size_t size, void *buffer) {
fprintf(stderr, "Error: writing to DMGs is not supported (impossible to achieve with compressed images and retain asr multicast ordering).\n");
// hamstergene: is it really that hard? Doesn't seem so to me.
return FALSE;
}
@ -224,7 +225,16 @@ io_func* openDmgFile(AbstractFile* abstractIn) {
}
io_func* openDmgFilePartition(AbstractFile* abstractIn, int partition) {
io_func* toReturn;
io_func* toReturn = openDmgFile(abstractIn);
if(toReturn == NULL) {
return NULL;
}
return seekDmgPartition(toReturn, partition);
}
io_func* seekDmgPartition(io_func* toReturn, int partition) {
Partition* partitions;
uint8_t ddmBuffer[SECTOR_SIZE];
DriverDescriptorRecord* ddm;
@ -232,12 +242,6 @@ io_func* openDmgFilePartition(AbstractFile* abstractIn, int partition) {
int i;
unsigned int BlockSize;
toReturn = openDmgFile(abstractIn);
if(toReturn == NULL) {
return NULL;
}
toReturn->read(toReturn, 0, SECTOR_SIZE, ddmBuffer);
ddm = (DriverDescriptorRecord*) ddmBuffer;
flipDriverDescriptorRecord(ddm, FALSE);

Просмотреть файл

@ -7,6 +7,9 @@
#include <dmg/dmg.h>
io_func* openDmgFile(AbstractFile* dmg);
io_func* seekDmgPartition(io_func*, int partition);
// combines openDmgFile+seekDmgPartition
io_func* openDmgFilePartition(AbstractFile* dmg, int partition);
typedef struct DMG {