iso-info now does something useful now that readdir routine fixed up for

iso images.
This commit is contained in:
rocky
2004-01-10 03:21:50 +00:00
parent 3d6e147070
commit 46689e587d
3 changed files with 72 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: iso9660.h,v 1.35 2004/01/10 03:03:08 rocky Exp $
$Id: iso9660.h,v 1.36 2004/01/10 03:21:50 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -446,7 +446,7 @@ void * iso9660_fs_readdir (const CdIo *obj, const char pathname[], bool mode2);
Read pathname (a directory) and return a list of iso9660_stat_t
of the files inside that. The caller must free the returned result.
*/
void * iso9660_ifs_readdir (const iso9660_t *iso, const char pathname[]);
void * iso9660_ifs_readdir (iso9660_t *iso, const char pathname[]);
uint8_t iso9660_get_dir_len(const iso9660_dir_t *idr);

View File

@@ -1,5 +1,5 @@
/*
$Id: iso9660_fs.c,v 1.14 2004/01/10 03:03:08 rocky Exp $
$Id: iso9660_fs.c,v 1.15 2004/01/10 03:21:50 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -40,7 +40,7 @@
#include <stdio.h>
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.14 2004/01/10 03:03:08 rocky Exp $";
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.15 2004/01/10 03:21:50 rocky Exp $";
/* Implementation of iso9660_t type */
struct _iso9660 {
@@ -431,8 +431,8 @@ iso9660_fs_readdir (const CdIo *cdio, const char pathname[], bool is_mode2)
{
iso9660_stat_t *stat;
cdio_assert (cdio != NULL);
cdio_assert (pathname != NULL);
if (NULL == cdio) return NULL;
if (NULL == pathname) return NULL;
stat = iso9660_fs_stat (cdio, pathname, is_mode2);
if (NULL == stat)
@@ -492,6 +492,69 @@ iso9660_fs_readdir (const CdIo *cdio, const char pathname[], bool is_mode2)
}
}
/*!
Read pathname (a directory) and return a list of iso9660_stat_t
of the files inside that. The caller must free the returned result.
*/
void *
iso9660_ifs_readdir (iso9660_t *iso, const char pathname[])
{
iso9660_stat_t *stat;
if (NULL == iso) return NULL;
if (NULL == pathname) return NULL;
stat = iso9660_ifs_stat (iso, pathname);
if (NULL == stat) return NULL;
if (stat->type != _STAT_DIR) {
free(stat);
return NULL;
}
{
long int ret;
unsigned offset = 0;
uint8_t *_dirbuf = NULL;
CdioList *retval = _cdio_list_new ();
if (stat->size != ISO_BLOCKSIZE * stat->secsize)
{
cdio_warn ("bad size for ISO9660 directory (%ud) should be (%lu)!",
(unsigned) stat->size,
(unsigned long int) ISO_BLOCKSIZE * stat->secsize);
}
_dirbuf = _cdio_malloc (stat->secsize * ISO_BLOCKSIZE);
ret = iso9660_iso_seek_read (iso, _dirbuf, stat->lsn, stat->secsize);
if (ret != ISO_BLOCKSIZE*stat->secsize) return NULL;
while (offset < (stat->secsize * ISO_BLOCKSIZE))
{
const iso9660_dir_t *iso9660_dir = (void *) &_dirbuf[offset];
iso9660_stat_t *iso9660_stat;
if (!iso9660_get_dir_len(iso9660_dir))
{
offset++;
continue;
}
iso9660_stat = _iso9660_dir_to_statbuf(iso9660_dir, true);
_cdio_list_append (retval, iso9660_stat);
offset += iso9660_get_dir_len(iso9660_dir);
}
cdio_assert (offset == (stat->secsize * ISO_BLOCKSIZE));
free (_dirbuf);
free (stat);
return retval;
}
}
static iso9660_stat_t *
find_fs_lsn_recurse (const CdIo *cdio, const char pathname[], lsn_t lsn)
{

View File

@@ -1,7 +1,7 @@
/*
$Id: util.c,v 1.2 2003/10/28 16:23:50 rocky Exp $
$Id: util.c,v 1.3 2004/01/10 03:21:50 rocky Exp $
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ print_version (const char *program_name, const char *version,
driver_id_t driver_id;
if (no_header == 0)
printf( "%s version %s\nCopyright (c) 2003 R. Bernstein\n",
printf( "%s version %s\nCopyright (c) 2003, 2004 R. Bernstein\n",
program_name, version);
printf( _("This is free software; see the source for copying conditions.\n\
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\