mirror of
https://github.com/vivier/EMILE.git
synced 2024-09-08 19:54:38 +00:00
allow to read image file instead of /dev/cdrom
This commit is contained in:
parent
a472cae367
commit
9aa7430439
@ -13,8 +13,6 @@
|
|||||||
#define SECTOR_SIZE (2048)
|
#define SECTOR_SIZE (2048)
|
||||||
#define ISO_BLOCKS(X) (((X) / SECTOR_SIZE) + (((X)%SECTOR_SIZE)?1:0))
|
#define ISO_BLOCKS(X) (((X) / SECTOR_SIZE) + (((X)%SECTOR_SIZE)?1:0))
|
||||||
|
|
||||||
static const char *filename = "/dev/cdrom";
|
|
||||||
|
|
||||||
int device_read_sector(void *data,off_t offset, void* buffer, size_t size)
|
int device_read_sector(void *data,off_t offset, void* buffer, size_t size)
|
||||||
{
|
{
|
||||||
FILE* file = (FILE*)data;
|
FILE* file = (FILE*)data;
|
||||||
@ -30,11 +28,14 @@ void device_close(void *data)
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *device_open(void)
|
FILE *device_open(char *device)
|
||||||
{
|
{
|
||||||
FILE* file;
|
FILE* file;
|
||||||
|
|
||||||
file = fopen(filename, "rb");
|
if (device == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
file = fopen(device, "rb");
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -10,6 +10,6 @@
|
|||||||
|
|
||||||
#include <libstream.h>
|
#include <libstream.h>
|
||||||
|
|
||||||
extern FILE *device_open(void);
|
extern FILE *device_open(char *device);
|
||||||
extern void device_close(void *data);
|
extern void device_close(void *data);
|
||||||
extern int device_read_sector(void *data, off_t offset, void* buffer, size_t size);
|
extern int device_read_sector(void *data, off_t offset, void* buffer, size_t size);
|
||||||
|
@ -25,8 +25,15 @@ int main(int argc, char **argv)
|
|||||||
iso9660_VOLUME *volume;
|
iso9660_VOLUME *volume;
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
size_t size;
|
size_t size;
|
||||||
|
int arg = 1;
|
||||||
|
char *devname;
|
||||||
|
|
||||||
device.data = device_open();
|
if (argc > 2)
|
||||||
|
devname = argv[arg++];
|
||||||
|
else
|
||||||
|
devname = "/dev/cdrom";
|
||||||
|
|
||||||
|
device.data = device_open(devname);
|
||||||
device.read_sector = (stream_read_sector_t)device_read_sector;
|
device.read_sector = (stream_read_sector_t)device_read_sector;
|
||||||
device.close = (stream_close_t)device_close;
|
device.close = (stream_close_t)device_close;
|
||||||
|
|
||||||
@ -34,8 +41,8 @@ int main(int argc, char **argv)
|
|||||||
if (volume == NULL)
|
if (volume == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > arg)
|
||||||
path = argv[1];
|
path = argv[arg++];
|
||||||
else
|
else
|
||||||
path = "/";
|
path = "/";
|
||||||
|
|
||||||
|
@ -44,8 +44,12 @@ int main(int argc, char **argv)
|
|||||||
char *path;
|
char *path;
|
||||||
device_io_t device;
|
device_io_t device;
|
||||||
iso9660_VOLUME *volume;
|
iso9660_VOLUME *volume;
|
||||||
|
int arg = 1;
|
||||||
|
|
||||||
device.data = device_open();
|
if (argc > 1)
|
||||||
|
device.data = device_open(argv[arg++]);
|
||||||
|
else
|
||||||
|
device.data = device_open("/dev/cdrom");
|
||||||
device.read_sector = (stream_read_sector_t)device_read_sector;
|
device.read_sector = (stream_read_sector_t)device_read_sector;
|
||||||
device.close = (stream_close_t)device_close;
|
device.close = (stream_close_t)device_close;
|
||||||
|
|
||||||
@ -53,8 +57,8 @@ int main(int argc, char **argv)
|
|||||||
if (volume == NULL)
|
if (volume == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > arg)
|
||||||
path = argv[1];
|
path = argv[arg];
|
||||||
else
|
else
|
||||||
path = "/";
|
path = "/";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user