mirror of
https://github.com/vivier/EMILE.git
synced 2024-10-02 03:56:45 +00:00
load binary image from disk
This commit is contained in:
parent
c680062e0c
commit
4e162a6fd7
45
second/load.c
Normal file
45
second/load.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include "glue.h"
|
||||
#include "load.h"
|
||||
|
||||
char* load_image(unsigned long offset, unsigned long size)
|
||||
{
|
||||
int err;
|
||||
char* image;
|
||||
ParamBlockRec_t param_block;
|
||||
|
||||
if (size == 0)
|
||||
return NULL;
|
||||
|
||||
image = malloc(size);
|
||||
if (image == 0)
|
||||
{
|
||||
free(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(¶m_block, 0, sizeof(param_block));
|
||||
|
||||
param_block.ioBuffer = (unsigned long)image;
|
||||
param_block.ioVRefNum = 1;
|
||||
param_block.ioRefNum = -5;
|
||||
param_block.ioReqCount = size;
|
||||
param_block.ioPosMode = fsFromStart;
|
||||
param_block.ioPosOffset = offset;
|
||||
|
||||
err = PBReadSync(¶m_block);
|
||||
if (err != noErr)
|
||||
{
|
||||
free(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
7
second/load.h
Normal file
7
second/load.h
Normal file
@ -0,0 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
extern char* load_image(unsigned long offset, unsigned long size);
|
Loading…
Reference in New Issue
Block a user