Add iso9660_name_translate() to remove ISO-name cruft.
Document iso9660_fs_stat().
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: iso9660.h,v 1.17 2003/09/05 22:48:16 rocky Exp $
|
$Id: iso9660.h,v 1.18 2003/09/06 14:50:50 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -184,6 +184,16 @@ bool iso9660_isdchar (int c);
|
|||||||
*/
|
*/
|
||||||
bool iso9660_isachar (int c);
|
bool iso9660_isachar (int c);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Convert ISO-9660 file name that stored in a directory entry into
|
||||||
|
what's usually listed as the file name in a listing.
|
||||||
|
Lowercase name, and drop deal with trailing ;1's or .;1's or
|
||||||
|
; version numbers.
|
||||||
|
|
||||||
|
The length of the translated string is returned.
|
||||||
|
*/
|
||||||
|
int iso9660_name_translate(const char *old, char *new);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Pad string src with spaces to size len and copy this to dst. If
|
Pad string src with spaces to size len and copy this to dst. If
|
||||||
len is less than the length of src, dst will be truncated to the
|
len is less than the length of src, dst will be truncated to the
|
||||||
@@ -263,13 +273,15 @@ iso9660_dir_calc_record_size (unsigned int namelen, unsigned int su_len);
|
|||||||
|
|
||||||
Returns true if we found an entry with the lsn and false if not.
|
Returns true if we found an entry with the lsn and false if not.
|
||||||
*/
|
*/
|
||||||
bool
|
bool iso9660_find_fs_lsn(const CdIo *cdio, lsn_t lsn,
|
||||||
iso9660_find_fs_lsn(const CdIo *cdio, lsn_t lsn, /*out*/ iso9660_stat_t *stat);
|
/*out*/ iso9660_stat_t *stat);
|
||||||
|
|
||||||
|
/*!
|
||||||
int
|
Get file status for pathname into stat. As with libc's stat, 0 is returned
|
||||||
iso9660_fs_stat (const CdIo *obj, const char pathname[], iso9660_stat_t *buf,
|
if no error and -1 on error.
|
||||||
bool is_mode2);
|
*/
|
||||||
|
int iso9660_fs_stat (const CdIo *obj, const char pathname[],
|
||||||
|
/*out*/ iso9660_stat_t *stat, bool is_mode2);
|
||||||
|
|
||||||
void * /* list of char* -- caller must free it */
|
void * /* list of char* -- caller must free it */
|
||||||
iso9660_fs_readdir (const CdIo *obj, const char pathname[], bool mode2);
|
iso9660_fs_readdir (const CdIo *obj, const char pathname[], bool mode2);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: iso9660.c,v 1.7 2003/09/01 15:10:43 rocky Exp $
|
$Id: iso9660.c,v 1.8 2003/09/06 14:50:50 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -19,9 +19,14 @@
|
|||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
/* Private headers */
|
||||||
# include "config.h"
|
#include "iso9660_private.h"
|
||||||
#endif
|
#include "cdio_assert.h"
|
||||||
|
#include "bytesex.h"
|
||||||
|
|
||||||
|
/* Public headers */
|
||||||
|
#include <cdio/iso9660.h>
|
||||||
|
#include <cdio/util.h>
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -32,16 +37,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Public headers */
|
static const char _rcsid[] = "$Id: iso9660.c,v 1.8 2003/09/06 14:50:50 rocky Exp $";
|
||||||
#include <cdio/iso9660.h>
|
|
||||||
#include <cdio/util.h>
|
|
||||||
|
|
||||||
/* Private headers */
|
|
||||||
#include "iso9660_private.h"
|
|
||||||
#include "cdio_assert.h"
|
|
||||||
#include "bytesex.h"
|
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: iso9660.c,v 1.7 2003/09/01 15:10:43 rocky Exp $";
|
|
||||||
|
|
||||||
/* some parameters... */
|
/* some parameters... */
|
||||||
#define SYSTEM_ID "CD-RTOS CD-BRIDGE"
|
#define SYSTEM_ID "CD-RTOS CD-BRIDGE"
|
||||||
@@ -86,6 +82,46 @@ _pvd_set_time (char _pvd_date[], const struct tm *_tm)
|
|||||||
_pvd_date[16] = (int8_t) 0; /* tz */
|
_pvd_date[16] = (int8_t) 0; /* tz */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Convert ISO-9660 file name that stored in a directory entry into
|
||||||
|
what's usually listed as the file name in a listing.
|
||||||
|
Lowercase name, and trailing ;1's or .;1's and turn the
|
||||||
|
other ;'s into version numbers.
|
||||||
|
|
||||||
|
The length of the translated string is returned.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
iso9660_name_translate(const char *old, char *new)
|
||||||
|
{
|
||||||
|
int len = strlen(old);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
unsigned char c = old[i];
|
||||||
|
if (!c)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* lower case */
|
||||||
|
if (isupper(c)) c = tolower(c);
|
||||||
|
|
||||||
|
/* Drop trailing '.;1' (ISO 9660:1988 7.5.1 requires period) */
|
||||||
|
if (c == '.' && i == len - 3 && old[i + 1] == ';' && old[i + 2] == '1')
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Drop trailing ';1' */
|
||||||
|
if (c == ';' && i == len - 2 && old[i + 1] == '1')
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Convert remaining ';' to '.' */
|
||||||
|
if (c == ';')
|
||||||
|
c = '.';
|
||||||
|
|
||||||
|
new[i] = c;
|
||||||
|
}
|
||||||
|
new[i] = '\0';
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Pad string src with spaces to size len and copy this to dst. If
|
Pad string src with spaces to size len and copy this to dst. If
|
||||||
len is less than the length of src, dst will be truncated to the
|
len is less than the length of src, dst will be truncated to the
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: iso9660_fs.c,v 1.6 2003/09/05 22:48:16 rocky Exp $
|
$Id: iso9660_fs.c,v 1.7 2003/09/06 14:50:50 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.6 2003/09/05 22:48:16 rocky Exp $";
|
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.7 2003/09/06 14:50:50 rocky Exp $";
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_idr2statbuf (const iso9660_dir_t *idr, iso9660_stat_t *buf, bool is_mode2)
|
_idr2statbuf (const iso9660_dir_t *idr, iso9660_stat_t *buf, bool is_mode2)
|
||||||
@@ -201,9 +201,13 @@ _fs_stat_traverse (const CdIo *cdio, const iso9660_stat_t *_root,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get file status for pathname into stat. As with libc's stat, 0 is returned
|
||||||
|
if no error and -1 on error.
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
iso9660_fs_stat (const CdIo *cdio, const char pathname[], iso9660_stat_t *buf,
|
iso9660_fs_stat (const CdIo *cdio, const char pathname[],
|
||||||
bool is_mode2)
|
/*out*/ iso9660_stat_t *stat, bool is_mode2)
|
||||||
{
|
{
|
||||||
iso9660_stat_t _root;
|
iso9660_stat_t _root;
|
||||||
int retval;
|
int retval;
|
||||||
@@ -211,12 +215,12 @@ iso9660_fs_stat (const CdIo *cdio, const char pathname[], iso9660_stat_t *buf,
|
|||||||
|
|
||||||
cdio_assert (cdio != NULL);
|
cdio_assert (cdio != NULL);
|
||||||
cdio_assert (pathname != NULL);
|
cdio_assert (pathname != NULL);
|
||||||
cdio_assert (buf != NULL);
|
cdio_assert (stat != NULL);
|
||||||
|
|
||||||
_fs_stat_root (cdio, &_root, is_mode2);
|
_fs_stat_root (cdio, &_root, is_mode2);
|
||||||
|
|
||||||
splitpath = _cdio_strsplit (pathname, '/');
|
splitpath = _cdio_strsplit (pathname, '/');
|
||||||
retval = _fs_stat_traverse (cdio, &_root, splitpath, buf, is_mode2);
|
retval = _fs_stat_traverse (cdio, &_root, splitpath, stat, is_mode2);
|
||||||
_cdio_strfreev (splitpath);
|
_cdio_strfreev (splitpath);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: iso9660_private.h,v 1.5 2003/09/01 02:08:59 rocky Exp $
|
$Id: iso9660_private.h,v 1.6 2003/09/06 14:50:50 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -27,6 +27,10 @@
|
|||||||
#ifndef __CDIO_ISO9660_PRIVATE_H__
|
#ifndef __CDIO_ISO9660_PRIVATE_H__
|
||||||
#define __CDIO_ISO9660_PRIVATE_H__
|
#define __CDIO_ISO9660_PRIVATE_H__
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cdio/types.h>
|
#include <cdio/types.h>
|
||||||
|
|
||||||
#define ISO_VERSION 1
|
#define ISO_VERSION 1
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cd-info.c,v 1.31 2003/09/01 22:31:46 rocky Exp $
|
$Id: cd-info.c,v 1.32 2003/09/06 14:50:50 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
Copyright (C) 1996,1997,1998 Gerd Knorr <kraxel@bytesex.org>
|
Copyright (C) 1996,1997,1998 Gerd Knorr <kraxel@bytesex.org>
|
||||||
@@ -612,15 +612,19 @@ print_iso9660_recurse (CdIo *cdio, const char pathname[], cdio_fs_anal_t fs,
|
|||||||
|
|
||||||
cdio_assert (entlist != NULL);
|
cdio_assert (entlist != NULL);
|
||||||
|
|
||||||
/* just iterate */
|
/* Iterate over files in this directory */
|
||||||
|
|
||||||
_CDIO_LIST_FOREACH (entnode, entlist)
|
_CDIO_LIST_FOREACH (entnode, entlist)
|
||||||
{
|
{
|
||||||
char *_name = _cdio_list_node_data (entnode);
|
char *iso_name = _cdio_list_node_data (entnode);
|
||||||
char _fullname[4096] = { 0, };
|
char _fullname[4096] = { 0, };
|
||||||
iso9660_stat_t statbuf;
|
iso9660_stat_t statbuf;
|
||||||
|
char translated_name[MAX_ISONAME+1];
|
||||||
|
|
||||||
snprintf (_fullname, sizeof (_fullname), "%s%s", pathname, _name);
|
iso9660_name_translate(iso_name, translated_name);
|
||||||
|
|
||||||
|
snprintf (_fullname, sizeof (_fullname), "%s%s", pathname,
|
||||||
|
iso_name);
|
||||||
|
|
||||||
if (iso9660_fs_stat (cdio, _fullname, &statbuf, is_mode2))
|
if (iso9660_fs_stat (cdio, _fullname, &statbuf, is_mode2))
|
||||||
cdio_assert_not_reached ();
|
cdio_assert_not_reached ();
|
||||||
@@ -628,8 +632,8 @@ print_iso9660_recurse (CdIo *cdio, const char pathname[], cdio_fs_anal_t fs,
|
|||||||
strncat (_fullname, "/", sizeof (_fullname));
|
strncat (_fullname, "/", sizeof (_fullname));
|
||||||
|
|
||||||
if (statbuf.type == _STAT_DIR
|
if (statbuf.type == _STAT_DIR
|
||||||
&& strcmp (_name, ".")
|
&& strcmp (iso_name, ".")
|
||||||
&& strcmp (_name, ".."))
|
&& strcmp (iso_name, ".."))
|
||||||
_cdio_list_append (dirlist, strdup (_fullname));
|
_cdio_list_append (dirlist, strdup (_fullname));
|
||||||
|
|
||||||
if (fs & CDIO_FS_ANAL_XA) {
|
if (fs & CDIO_FS_ANAL_XA) {
|
||||||
@@ -649,14 +653,14 @@ print_iso9660_recurse (CdIo *cdio, const char pathname[], cdio_fs_anal_t fs,
|
|||||||
printf ("%9d", statbuf.size);
|
printf ("%9d", statbuf.size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf (" %s\n", _name);
|
printf (" %s\n", translated_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
_cdio_list_free (entlist, true);
|
_cdio_list_free (entlist, true);
|
||||||
|
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
|
|
||||||
/* now recurse */
|
/* Now wecurse over the directories. */
|
||||||
|
|
||||||
_CDIO_LIST_FOREACH (entnode, dirlist)
|
_CDIO_LIST_FOREACH (entnode, dirlist)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user