mirror of
https://github.com/vivier/EMILE.git
synced 2025-01-22 00:32:15 +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 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)
|
||||
{
|
||||
FILE* file = (FILE*)data;
|
||||
@ -30,11 +28,14 @@ void device_close(void *data)
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
FILE *device_open(void)
|
||||
FILE *device_open(char *device)
|
||||
{
|
||||
FILE* file;
|
||||
|
||||
file = fopen(filename, "rb");
|
||||
if (device == NULL)
|
||||
return NULL;
|
||||
|
||||
file = fopen(device, "rb");
|
||||
if (file == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -10,6 +10,6 @@
|
||||
|
||||
#include <libstream.h>
|
||||
|
||||
extern FILE *device_open(void);
|
||||
extern FILE *device_open(char *device);
|
||||
extern void device_close(void *data);
|
||||
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;
|
||||
char buffer[512];
|
||||
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.close = (stream_close_t)device_close;
|
||||
|
||||
@ -34,8 +41,8 @@ int main(int argc, char **argv)
|
||||
if (volume == NULL)
|
||||
return 1;
|
||||
|
||||
if (argc > 1)
|
||||
path = argv[1];
|
||||
if (argc > arg)
|
||||
path = argv[arg++];
|
||||
else
|
||||
path = "/";
|
||||
|
||||
|
@ -44,8 +44,12 @@ int main(int argc, char **argv)
|
||||
char *path;
|
||||
device_io_t device;
|
||||
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.close = (stream_close_t)device_close;
|
||||
|
||||
@ -53,8 +57,8 @@ int main(int argc, char **argv)
|
||||
if (volume == NULL)
|
||||
return -1;
|
||||
|
||||
if (argc > 1)
|
||||
path = argv[1];
|
||||
if (argc > arg)
|
||||
path = argv[arg];
|
||||
else
|
||||
path = "/";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user