Some small changes inspired by correspoinding Perl programs.

This commit is contained in:
rocky
2006-03-02 01:28:58 +00:00
parent b8375748c5
commit d4ea2bfcaf
3 changed files with 25 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: iso1.cpp,v 1.3 2006/03/01 14:11:16 rocky Exp $
$Id: iso1.cpp,v 1.4 2006/03/02 01:28:58 rocky Exp $
Copyright (C) 2004, 2006 Rocky Bernstein <rocky@panix.com>
@@ -64,6 +64,7 @@ main(int argc, const char *argv[])
CdioListNode_t *p_entnode;
char const *psz_fname;
iso9660_t *p_iso;
const char *psz_path="/";
if (argc > 1)
psz_fname = argv[1];
@@ -78,7 +79,7 @@ main(int argc, const char *argv[])
return 1;
}
p_entlist = iso9660_ifs_readdir (p_iso, "/");
p_entlist = iso9660_ifs_readdir (p_iso, psz_path);
/* Iterate over the list of nodes that iso9660_ifs_readdir gives */
@@ -89,7 +90,9 @@ main(int argc, const char *argv[])
iso9660_stat_t *p_statbuf =
(iso9660_stat_t *) _cdio_list_node_data (p_entnode);
iso9660_name_translate(p_statbuf->filename, filename);
printf ("/%s\n", filename);
printf ("%s [LSN %6d] %8u %s%s\n",
2 == p_statbuf->type ? "d" : "-",
p_statbuf->lsn, p_statbuf->size, psz_path, filename);
}
_cdio_list_free (p_entlist, true);

View File

@@ -1,5 +1,5 @@
/*
$Id: iso1.c,v 1.8 2006/03/01 15:16:16 rocky Exp $
$Id: iso1.c,v 1.9 2006/03/02 01:28:58 rocky Exp $
Copyright (C) 2004, 2005, 2006 Rocky Bernstein <rocky@panix.com>
@@ -60,6 +60,7 @@ main(int argc, const char *argv[])
CdioListNode_t *p_entnode;
char const *psz_fname;
iso9660_t *p_iso;
const char *psz_path="/";
if (argc > 1)
psz_fname = argv[1];
@@ -74,7 +75,7 @@ main(int argc, const char *argv[])
return 1;
}
p_entlist = iso9660_ifs_readdir (p_iso, "/");
p_entlist = iso9660_ifs_readdir (p_iso, psz_path);
/* Iterate over the list of nodes that iso9660_ifs_readdir gives */
@@ -85,7 +86,9 @@ main(int argc, const char *argv[])
iso9660_stat_t *p_statbuf =
(iso9660_stat_t *) _cdio_list_node_data (p_entnode);
iso9660_name_translate(p_statbuf->filename, filename);
printf ("/%s\n", filename);
printf ("%s [LSN %6d] %8u %s%s\n",
_STAT_DIR == p_statbuf->type ? "d" : "-",
p_statbuf->lsn, p_statbuf->size, psz_path, filename);
}
_cdio_list_free (p_entlist, true);

View File

@@ -1,5 +1,5 @@
/*
$Id: iso3.c,v 1.5 2005/11/07 07:44:00 rocky Exp $
$Id: iso3.c,v 1.6 2006/03/02 01:28:58 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -60,6 +60,8 @@
#include <sys/types.h>
#endif
#define CEILING(x, y) ((x+(y-1))/y)
#define my_exit(rc) \
fclose (p_outfd); \
free(p_statbuf); \
@@ -107,22 +109,22 @@ main(int argc, const char *argv[])
}
/* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */
for (i = 0; i < p_statbuf->size; i += ISO_BLOCKSIZE)
{
const unsigned int i_blocks = CEILING(p_statbuf->size, ISO_BLOCKSIZE);
for (i = 0; i < i_blocks ; i++)
{
char buf[ISO_BLOCKSIZE];
const lsn_t lsn = p_statbuf->lsn + i;
memset (buf, 0, ISO_BLOCKSIZE);
if ( ISO_BLOCKSIZE != iso9660_iso_seek_read (p_iso, buf, p_statbuf->lsn
+ (i / ISO_BLOCKSIZE),
1) )
if ( ISO_BLOCKSIZE != iso9660_iso_seek_read (p_iso, buf, lsn, 1) )
{
fprintf(stderr, "Error reading ISO 9660 file at lsn %lu\n",
(long unsigned int) p_statbuf->lsn + (i / ISO_BLOCKSIZE));
fprintf(stderr, "Error reading ISO 9660 file %s at LSN %lu\n",
LOCAL_FILENAME, (long unsigned int) lsn);
my_exit(4);
}
fwrite (buf, ISO_BLOCKSIZE, 1, p_outfd);
if (ferror (p_outfd))
@@ -131,6 +133,7 @@ main(int argc, const char *argv[])
my_exit(5);
}
}
}
fflush (p_outfd);
@@ -140,7 +143,8 @@ main(int argc, const char *argv[])
if (ftruncate (fileno (p_outfd), p_statbuf->size))
perror ("ftruncate()");
printf("Extraction of file 'copying' from %s successful.\n", ISO9660_IMAGE);
printf("Extraction of file '%s' from %s successful.\n",
LOCAL_FILENAME, ISO9660_IMAGE);
my_exit(0);
}