diff --git a/NEWS b/NEWS index e6dbfceb..875c4a50 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +0.67 +- portability fix, for ARM e.g +-- add iso-read program +-- libiso9960: stat routines that match level 1 ISO-9600 filenames + translating them into Unix-style names (i.e. lowercase letters, + with version numbers dropped.) + 0.66 - Add interface for reading an ISO-9660 image - portability fixes (Solaris, cygwin) @@ -83,4 +90,6 @@ - Bugs fixed (default device name on linux), 0.1 - Routines split off from VCDImager. \ No newline at end of file + Routines split off from VCDImager. + +$Id: NEWS,v 1.31 2004/02/26 00:13:24 rocky Exp $ diff --git a/example/sample7.c b/example/sample7.c index 7d5a73e9..8e418879 100644 --- a/example/sample7.c +++ b/example/sample7.c @@ -1,5 +1,5 @@ /* - $Id: sample7.c,v 1.3 2004/02/01 17:13:42 rocky Exp $ + $Id: sample7.c,v 1.4 2004/02/26 00:13:24 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -25,7 +25,6 @@ #define ISO9660_IMAGE_PATH "../" #define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/copying.iso" -#define ISO9660_FILENAME "/COPYING.;1" #define LOCAL_FILENAME "copying" #ifdef HAVE_CONFIG_H @@ -36,10 +35,19 @@ #include #include + +#ifdef HAVE_ERRNO_H #include +#endif +#ifdef HAVE_STRING_H #include +#endif +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef HAVE_SYS_TYPES_H #include +#endif int main(int argc, const char *argv[]) @@ -55,17 +63,17 @@ main(int argc, const char *argv[]) return 1; } - statbuf = iso9660_ifs_stat (iso, ISO9660_FILENAME); + statbuf = iso9660_ifs_stat_translate (iso, LOCAL_FILENAME); if (NULL == statbuf) { fprintf(stderr, "Could not get ISO-9660 file information for file %s\n", - ISO9660_FILENAME); + LOCAL_FILENAME); return 2; } - if (!(outfd = fopen ("copying", "wb"))) + if (!(outfd = fopen (LOCAL_FILENAME, "wb"))) { perror ("fopen()"); return 3; diff --git a/include/cdio/iso9660.h b/include/cdio/iso9660.h index db53816e..63dc99a8 100644 --- a/include/cdio/iso9660.h +++ b/include/cdio/iso9660.h @@ -1,5 +1,5 @@ /* - $Id: iso9660.h,v 1.38 2004/01/18 15:07:57 rocky Exp $ + $Id: iso9660.h,v 1.39 2004/02/26 00:13:24 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003, 2004 Rocky Bernstein @@ -430,12 +430,32 @@ iso9660_stat_t *iso9660_find_ifs_lsn(const iso9660_t *iso, lsn_t lsn); iso9660_stat_t *iso9660_fs_stat (const CdIo *obj, const char pathname[], bool is_mode2); +/*! + Get file status for pathname into stat. NULL is returned on error. + pathname version numbers in the ISO 9660 + name are dropped, i.e. ;1 is removed and if level 1 ISO-9660 names + are lowercased. + */ +iso9660_stat_t *iso9660_fs_stat_translate (const CdIo *obj, + const char pathname[], + bool is_mode2); + /*! Get file status for pathname into stat. NULL is returned on error. */ void *iso9660_ifs_stat (iso9660_t *iso, const char pathname[]); +/*! + Get file status for pathname into stat. NULL is returned on error. + pathname version numbers in the ISO 9660 + name are dropped, i.e. ;1 is removed and if level 1 ISO-9660 names + are lowercased. + */ +void *iso9660_ifs_stat_translate (iso9660_t *iso, const char pathname[]); + + + /*! Read pathname (a directory) and return a list of iso9660_stat_t of the files inside that. The caller must free the returned result. diff --git a/lib/iso9660_fs.c b/lib/iso9660_fs.c index 778a57f5..f3c16143 100644 --- a/lib/iso9660_fs.c +++ b/lib/iso9660_fs.c @@ -1,5 +1,5 @@ /* - $Id: iso9660_fs.c,v 1.16 2004/02/07 18:53:02 rocky Exp $ + $Id: iso9660_fs.c,v 1.17 2004/02/26 00:13:24 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003, 2004 Rocky Bernstein @@ -40,7 +40,7 @@ #include -static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.16 2004/02/07 18:53:02 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.17 2004/02/26 00:13:24 rocky Exp $"; /* Implementation of iso9660_t type */ struct _iso9660 { @@ -233,7 +233,7 @@ _fs_stat_iso_root (iso9660_t *iso) static iso9660_stat_t * _fs_stat_traverse (const CdIo *cdio, const iso9660_stat_t *_root, - char **splitpath, bool is_mode2) + char **splitpath, bool is_mode2, bool translate) { unsigned offset = 0; uint8_t *_dirbuf = NULL; @@ -275,6 +275,7 @@ _fs_stat_traverse (const CdIo *cdio, const iso9660_stat_t *_root, { const iso9660_dir_t *iso9660_dir = (void *) &_dirbuf[offset]; iso9660_stat_t *stat; + int cmp; if (!iso9660_get_dir_len(iso9660_dir)) { @@ -284,14 +285,29 @@ _fs_stat_traverse (const CdIo *cdio, const iso9660_stat_t *_root, stat = _iso9660_dir_to_statbuf (iso9660_dir, is_mode2); - if (!strcmp (splitpath[0], stat->filename)) - { - iso9660_stat_t *ret_stat - = _fs_stat_traverse (cdio, stat, &splitpath[1], is_mode2); - free(stat); - free (_dirbuf); - return ret_stat; + if (translate) { + char *trans_fname = malloc(strlen(stat->filename)); + int trans_len; + + if (trans_fname == NULL) { + cdio_warn("can't allocate %u bytes", strlen(stat->filename)); + return NULL; } + trans_len = iso9660_name_translate(stat->filename, trans_fname); + cmp = strcmp(splitpath[0], trans_fname); + free(trans_fname); + } else { + cmp = strcmp(splitpath[0], stat->filename); + } + + if (!cmp) { + iso9660_stat_t *ret_stat + = _fs_stat_traverse (cdio, stat, &splitpath[1], is_mode2, + translate); + free(stat); + free (_dirbuf); + return ret_stat; + } free(stat); @@ -307,7 +323,7 @@ _fs_stat_traverse (const CdIo *cdio, const iso9660_stat_t *_root, static iso9660_stat_t * _fs_iso_stat_traverse (iso9660_t *iso, const iso9660_stat_t *_root, - char **splitpath) + char **splitpath, bool translate) { unsigned offset = 0; uint8_t *_dirbuf = NULL; @@ -343,6 +359,7 @@ _fs_iso_stat_traverse (iso9660_t *iso, const iso9660_stat_t *_root, { const iso9660_dir_t *iso9660_dir = (void *) &_dirbuf[offset]; iso9660_stat_t *stat; + int cmp; if (!iso9660_get_dir_len(iso9660_dir)) { @@ -352,14 +369,28 @@ _fs_iso_stat_traverse (iso9660_t *iso, const iso9660_stat_t *_root, stat = _iso9660_dir_to_statbuf (iso9660_dir, true); - if (!strcmp (splitpath[0], stat->filename)) - { - iso9660_stat_t *ret_stat - = _fs_iso_stat_traverse (iso, stat, &splitpath[1]); - free(stat); - free (_dirbuf); - return ret_stat; + if (translate) { + char *trans_fname = malloc(strlen(stat->filename)); + int trans_len; + + if (trans_fname == NULL) { + cdio_warn("can't allocate %u bytes", strlen(stat->filename)); + return NULL; } + trans_len = iso9660_name_translate(stat->filename, trans_fname); + cmp = strcmp(splitpath[0], trans_fname); + free(trans_fname); + } else { + cmp = strcmp(splitpath[0], stat->filename); + } + + if (!cmp) { + iso9660_stat_t *ret_stat + = _fs_iso_stat_traverse (iso, stat, &splitpath[1], translate); + free(stat); + free (_dirbuf); + return ret_stat; + } free(stat); @@ -390,7 +421,35 @@ iso9660_fs_stat (const CdIo *cdio, const char pathname[], bool is_mode2) if (NULL == root) return NULL; splitpath = _cdio_strsplit (pathname, '/'); - stat = _fs_stat_traverse (cdio, root, splitpath, is_mode2); + stat = _fs_stat_traverse (cdio, root, splitpath, is_mode2, false); + free(root); + _cdio_strfreev (splitpath); + + return stat; +} + +/*! + Get file status for pathname into stat. NULL is returned on error. + pathname version numbers in the ISO 9660 + name are dropped, i.e. ;1 is removed and if level 1 ISO-9660 names + are lowercased. + */ +iso9660_stat_t * +iso9660_fs_stat_translate (const CdIo *cdio, const char pathname[], + bool is_mode2) +{ + iso9660_stat_t *root; + char **splitpath; + iso9660_stat_t *stat; + + if (cdio == NULL) return NULL; + if (pathname == NULL) return NULL; + + root = _fs_stat_root (cdio, is_mode2); + if (NULL == root) return NULL; + + splitpath = _cdio_strsplit (pathname, '/'); + stat = _fs_stat_traverse (cdio, root, splitpath, is_mode2, true); free(root); _cdio_strfreev (splitpath); @@ -414,13 +473,39 @@ iso9660_ifs_stat (iso9660_t *iso, const char pathname[]) if (NULL == root) return NULL; splitpath = _cdio_strsplit (pathname, '/'); - stat = _fs_iso_stat_traverse (iso, root, splitpath); + stat = _fs_iso_stat_traverse (iso, root, splitpath, false); free(root); _cdio_strfreev (splitpath); return stat; } +/*! + Get file status for pathname into stat. NULL is returned on error. + pathname version numbers in the ISO 9660 + name are dropped, i.e. ;1 is removed and if level 1 ISO-9660 names + are lowercased. + */ +void * +iso9660_ifs_stat_translate (iso9660_t *iso, const char pathname[]) +{ + iso9660_stat_t *root; + char **splitpath; + iso9660_stat_t *stat; + + if (iso == NULL) return NULL; + if (pathname == NULL) return NULL; + + root = _fs_stat_iso_root (iso); + if (NULL == root) return NULL; + + splitpath = _cdio_strsplit (pathname, '/'); + stat = _fs_iso_stat_traverse (iso, root, splitpath, true); + free(root); + _cdio_strfreev (splitpath); + + return stat; +} /*! Read pathname (a directory) and return a list of iso9660_stat_t diff --git a/src/iso-read.c b/src/iso-read.c index 3a956122..2a52c916 100644 --- a/src/iso-read.c +++ b/src/iso-read.c @@ -1,5 +1,5 @@ /* - $Id: iso-read.c,v 1.1 2004/02/25 10:03:27 rocky Exp $ + $Id: iso-read.c,v 1.2 2004/02/26 00:13:24 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -180,7 +180,7 @@ main(int argc, const char *argv[]) return 1; } - statbuf = iso9660_ifs_stat (iso, opts.file_name); + statbuf = iso9660_ifs_stat_translate (iso, opts.file_name); if (NULL == statbuf) {