EMILE/tools/iso9660_ls.c

69 lines
1.1 KiB
C
Raw Normal View History

2005-11-13 19:43:28 +00:00
/*
*
* (c) 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
*
*/
2005-11-12 22:28:50 +00:00
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <stddef.h>
#include <string.h>
#include <libiso9660.h>
2005-11-13 19:43:28 +00:00
#include "device.h"
2005-11-21 22:07:17 +00:00
static void list(iso9660_VOLUME *volume, char *path)
2005-11-12 22:28:50 +00:00
{
char name_buf[256];
iso9660_DIR *dir;
struct iso_directory_record *idr;
2005-11-21 22:07:17 +00:00
dir = iso9660_opendir(volume, path);
2005-11-12 22:28:50 +00:00
if (dir == NULL)
return;
while ((idr = iso9660_readdir(dir)) != NULL)
{
2005-11-21 22:07:17 +00:00
iso9660_name(volume->ucs_level, name_buf, idr);
2005-11-12 22:28:50 +00:00
if (iso9660_is_directory(idr)) {
printf("%s/\n", name_buf);
} else {
printf("%s\n", name_buf);
}
}
iso9660_closedir(dir);
}
int main(int argc, char **argv)
{
char *path;
2005-11-21 22:07:17 +00:00
device_io_t device;
iso9660_VOLUME *volume;
2005-11-12 22:28:50 +00:00
2005-11-21 22:07:17 +00:00
device.data = device_open();
device.read_sector = (stream_read_sector_t)device_read_sector;
device.close = (stream_close_t)device_close;
2005-11-13 19:43:28 +00:00
2005-11-21 22:07:17 +00:00
volume = iso9660_mount(&device);
if (volume == NULL)
2005-11-12 22:28:50 +00:00
return -1;
if (argc > 1)
path = argv[1];
else
path = "/";
2005-11-21 22:07:17 +00:00
list(volume, path);
2005-11-12 22:28:50 +00:00
2005-11-21 22:07:17 +00:00
iso9660_umount(volume);
2005-11-12 22:28:50 +00:00
2005-11-21 22:07:17 +00:00
device_close(device.data);
2005-11-13 19:43:28 +00:00
2005-11-12 22:28:50 +00:00
return (0);
}