Start OO iso1.cpp.
iso3.cpp: valgrind lint. iso1.cpp: tidy more.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# $Id: Makefile.am,v 1.4 2006/03/06 01:34:22 rocky Exp $
|
# $Id: Makefile.am,v 1.5 2006/03/06 04:48:38 rocky Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) 2005, 2006 Rocky Bernstein <rocky@panix.com>
|
# Copyright (C) 2005, 2006 Rocky Bernstein <rocky@panix.com>
|
||||||
#
|
#
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
# Sample C++ programs using libcdio++ (with C++ OO wrapper)
|
# Sample C++ programs using libcdio++ (with C++ OO wrapper)
|
||||||
############################################################
|
############################################################
|
||||||
#
|
#
|
||||||
noinst_PROGRAMS = cdtext device drives eject iso3 mmc1 mmc2 tracks
|
noinst_PROGRAMS = cdtext device drives eject iso1 iso3 mmc1 mmc2 tracks
|
||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)/include $(LIBCDIO_CFLAGS)
|
INCLUDES = -I$(top_srcdir)/include $(LIBCDIO_CFLAGS)
|
||||||
|
|
||||||
@@ -40,6 +40,10 @@ eject_SOURCES = eject.cpp
|
|||||||
eject_DEPENDENCIES = $(LIBCDIO_DEPS)
|
eject_DEPENDENCIES = $(LIBCDIO_DEPS)
|
||||||
eject_LDADD = $(LIBCDIOPP_LIBS) $(LIBCDIO_LIBS)
|
eject_LDADD = $(LIBCDIOPP_LIBS) $(LIBCDIO_LIBS)
|
||||||
|
|
||||||
|
iso1_SOURCES = iso1.cpp
|
||||||
|
iso1_LDADD = $(LIBISO966PP0_LIBS) $(LIBISO9660_LIBS) \
|
||||||
|
$(LIBCDIOPP_LIBS) $(LIBICONV)
|
||||||
|
|
||||||
iso3_SOURCES = iso3.cpp
|
iso3_SOURCES = iso3.cpp
|
||||||
iso3_LDADD = $(LIBISO966PP0_LIBS) $(LIBISO9660_LIBS) \
|
iso3_LDADD = $(LIBISO966PP0_LIBS) $(LIBISO9660_LIBS) \
|
||||||
$(LIBCDIOPP_LIBS) $(LIBICONV)
|
$(LIBCDIOPP_LIBS) $(LIBICONV)
|
||||||
|
|||||||
120
example/C++/OO/iso1.cpp
Normal file
120
example/C++/OO/iso1.cpp
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
$Id: iso1.cpp,v 1.1 2006/03/06 04:48:38 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2006 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
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Simple program to show using libiso9660 to list files in a directory of
|
||||||
|
an ISO-9660 image and give some iso9660 information. See the code
|
||||||
|
to iso-info for a more complete example.
|
||||||
|
|
||||||
|
If a single argument is given, it is used as the ISO 9660 image to
|
||||||
|
use in the listing. Otherwise a compiled-in default ISO 9660 image
|
||||||
|
name (that comes with the libcdio distribution) will be used.
|
||||||
|
|
||||||
|
This program can be compiled with either a C or C++ compiler. In
|
||||||
|
the distributuion we perfer C++ just to make sure we haven't broken
|
||||||
|
things on the C++ side.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Set up a CD-DA image to test on which is in the libcdio distribution. */
|
||||||
|
#define ISO9660_IMAGE_PATH "../../../"
|
||||||
|
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/copying.iso"
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <cdio++/iso9660.hpp>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
#include <string.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define print_vd_info(title, fn) \
|
||||||
|
if (p_iso->fn(psz_str)) { \
|
||||||
|
printf(title ": %s\n", psz_str); \
|
||||||
|
} \
|
||||||
|
free(psz_str); \
|
||||||
|
psz_str = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, const char *argv[])
|
||||||
|
{
|
||||||
|
list < ISO9660::Stat > entlist;
|
||||||
|
ISO9660::IFS *p_iso = new ISO9660::IFS;
|
||||||
|
char const *psz_fname;
|
||||||
|
const char *psz_path="/";
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
psz_fname = argv[1];
|
||||||
|
else
|
||||||
|
psz_fname = ISO9660_IMAGE;
|
||||||
|
|
||||||
|
if (!p_iso->open(psz_fname)) {
|
||||||
|
fprintf(stderr, "Sorry, couldn't open %s as an ISO-9660 image\n",
|
||||||
|
psz_fname);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Show basic CD info from the Primary Volume Descriptor. */
|
||||||
|
{
|
||||||
|
char *psz_str = NULL;
|
||||||
|
print_vd_info("Application", get_application_id);
|
||||||
|
print_vd_info("Preparer ", get_preparer_id);
|
||||||
|
print_vd_info("Publisher ", get_publisher_id);
|
||||||
|
print_vd_info("System ", get_system_id);
|
||||||
|
print_vd_info("Volume ", get_volume_id);
|
||||||
|
print_vd_info("Volume Set ", get_volumeset_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
entlist = p_iso->readdir (psz_path);
|
||||||
|
|
||||||
|
/* Iterate over the list of nodes that iso9660_ifs_readdir gives */
|
||||||
|
|
||||||
|
{
|
||||||
|
ISO9660::Stat *p_stat;
|
||||||
|
for(p_stat=entlist.begin(); p_stat != entlist.end(); ++p_stat)
|
||||||
|
{
|
||||||
|
char filename[4096];
|
||||||
|
p_stat->iso9660_name_translate(p_statbuf->filename, filename);
|
||||||
|
printf ("%s [LSN %6d] %8u %s%s\n",
|
||||||
|
2 == p_statbuf->type ? "d" : "-",
|
||||||
|
p_statbuf->lsn, p_statbuf->size, psz_path, filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(stat);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
delete(p_iso);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: iso3.cpp,v 1.1 2006/03/06 01:34:22 rocky Exp $
|
$Id: iso3.cpp,v 1.2 2006/03/06 04:48:38 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2006 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2006 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -63,12 +63,14 @@
|
|||||||
|
|
||||||
#define my_exit(rc) \
|
#define my_exit(rc) \
|
||||||
fclose (p_outfd); \
|
fclose (p_outfd); \
|
||||||
|
delete (p_stat); \
|
||||||
|
delete (p_iso); \
|
||||||
return rc; \
|
return rc; \
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, const char *argv[])
|
main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
ISO9660::Stat *stat;
|
ISO9660::Stat *p_stat;
|
||||||
FILE *p_outfd;
|
FILE *p_outfd;
|
||||||
int i;
|
int i;
|
||||||
char const *psz_image;
|
char const *psz_image;
|
||||||
@@ -96,30 +98,32 @@ main(int argc, const char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
stat = p_iso->stat(psz_fname, true);
|
p_stat = p_iso->stat(psz_fname, true);
|
||||||
|
|
||||||
if (!stat)
|
if (!p_stat)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Could not get ISO-9660 file information for file %s\n",
|
"Could not get ISO-9660 file information for file %s\n",
|
||||||
psz_fname);
|
psz_fname);
|
||||||
p_iso->close();
|
delete(p_iso);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(p_outfd = fopen (psz_fname, "wb")))
|
if (!(p_outfd = fopen (psz_fname, "wb")))
|
||||||
{
|
{
|
||||||
perror ("fopen()");
|
perror ("fopen()");
|
||||||
|
delete (p_stat);
|
||||||
|
delete (p_iso);
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */
|
/* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */
|
||||||
{
|
{
|
||||||
const unsigned int i_blocks = CEILING(stat->p_stat->size, ISO_BLOCKSIZE);
|
const unsigned int i_blocks = CEILING(p_stat->p_stat->size, ISO_BLOCKSIZE);
|
||||||
for (i = 0; i < i_blocks ; i++)
|
for (i = 0; i < i_blocks ; i++)
|
||||||
{
|
{
|
||||||
char buf[ISO_BLOCKSIZE];
|
char buf[ISO_BLOCKSIZE];
|
||||||
const lsn_t lsn = stat->p_stat->lsn + i;
|
const lsn_t lsn = p_stat->p_stat->lsn + i;
|
||||||
|
|
||||||
memset (buf, 0, ISO_BLOCKSIZE);
|
memset (buf, 0, ISO_BLOCKSIZE);
|
||||||
|
|
||||||
@@ -145,7 +149,7 @@ main(int argc, const char *argv[])
|
|||||||
/* Make sure the file size has the exact same byte size. Without the
|
/* Make sure the file size has the exact same byte size. Without the
|
||||||
truncate below, the file will a multiple of ISO_BLOCKSIZE.
|
truncate below, the file will a multiple of ISO_BLOCKSIZE.
|
||||||
*/
|
*/
|
||||||
if (ftruncate (fileno (p_outfd), stat->p_stat->size))
|
if (ftruncate (fileno (p_outfd), p_stat->p_stat->size))
|
||||||
perror ("ftruncate()");
|
perror ("ftruncate()");
|
||||||
|
|
||||||
printf("Extraction of file '%s' from %s successful.\n",
|
printf("Extraction of file '%s' from %s successful.\n",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: iso1.cpp,v 1.5 2006/03/02 18:57:31 rocky Exp $
|
$Id: iso1.cpp,v 1.6 2006/03/06 04:48:37 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004, 2006 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004, 2006 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -38,8 +38,6 @@
|
|||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
#include <sys/types.h>
|
|
||||||
#include <cdio/cdio.h>
|
|
||||||
#include <cdio/iso9660.h>
|
#include <cdio/iso9660.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* -*- C++ -*-
|
/* -*- C++ -*-
|
||||||
$Id: iso9660.hpp,v 1.3 2006/03/06 01:34:22 rocky Exp $
|
$Id: iso9660.hpp,v 1.4 2006/03/06 04:48:38 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2006 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2006 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <cdio/iso9660.h>
|
#include <cdio/iso9660.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <list> // list class library
|
#include <list> // list class library
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
/** ISO 9660 class.
|
/** ISO 9660 class.
|
||||||
*/
|
*/
|
||||||
@@ -370,21 +371,26 @@ public:
|
|||||||
{
|
{
|
||||||
return iso9660_ifs_fuzzy_read_superblock (p_iso9660, iso_extension_mask,
|
return iso9660_ifs_fuzzy_read_superblock (p_iso9660, iso_extension_mask,
|
||||||
i_fuzz);
|
i_fuzz);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*! Read psz_path (a directory) and return a list of iso9660_stat_t
|
/*! Read psz_path (a directory) and return a list of iso9660_stat_t
|
||||||
pointers for the files inside that directory. The caller must free
|
pointers for the files inside that directory. The caller must free
|
||||||
the returned result.
|
the returned result.
|
||||||
*/
|
*/
|
||||||
list<Stat>::readdir (const char psz_path[])
|
list< ISO9660::Stat *> readdir (const char psz_path[])
|
||||||
{
|
{
|
||||||
CdioList_t *p_stat_list = iso9660_ifs_readdir (p_iso9660, psz_path);
|
CdioList_t *p_stat_list = iso9660_ifs_readdir (p_iso9660, psz_path);
|
||||||
list<Stat> stat_list;
|
CdioListNode_t *p_entnode;
|
||||||
|
list< ISO9660::Stat *> stat_list;
|
||||||
|
_CDIO_LIST_FOREACH (p_entnode, p_stat_list) {
|
||||||
|
iso9660_stat_t *p_statbuf =
|
||||||
|
(iso9660_stat_t *) _cdio_list_node_data (p_entnode);
|
||||||
|
stat_list.push_back(new ISO9660::Stat(p_statbuf));
|
||||||
}
|
}
|
||||||
#endif
|
_cdio_list_free (p_stat_list, false);
|
||||||
|
|
||||||
|
return stat_list;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Seek to a position and then read n bytes. Size read is returned.
|
Seek to a position and then read n bytes. Size read is returned.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# $Id: Makefile.am,v 1.3 2006/03/06 01:34:22 rocky Exp $
|
# $Id: Makefile.am,v 1.4 2006/03/06 04:48:38 rocky Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
# Copyright (C) 2005, 2006 Rocky Bernstein <rocky@panix.com>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
Reference in New Issue
Block a user