diff --git a/configure.ac b/configure.ac index 1627219c..c6e64407 100644 --- a/configure.ac +++ b/configure.ac @@ -19,7 +19,7 @@ define(RELEASE_NUM, 77) define(CDIO_VERSION_STR, 0.$1cvs) AC_PREREQ(2.52) -AC_REVISION([$Id: configure.ac,v 1.188 2006/03/07 02:38:44 rocky Exp $])dnl +AC_REVISION([$Id: configure.ac,v 1.189 2006/03/07 10:46:36 rocky Exp $])dnl AC_INIT(libcdio, CDIO_VERSION_STR(RELEASE_NUM)) AC_CONFIG_SRCDIR(src/cd-info.c) @@ -367,7 +367,7 @@ LIBUDF_LIBS='$(top_builddir)/lib/udf/libudf.la' AC_SUBST(LIBCDIO_CDDA_LIBS) AC_SUBST(LIBCDIO_CFLAGS) AC_SUBST(LIBISO9660_CFLAGS) -AC_SUBST(LIBCDISO9660PP_LIBS) +AC_SUBST(LIBISO9660PP_LIBS) AC_SUBST(LIBCDIO_LIBS) AC_SUBST(LIBCDIOPP_LIBS) AC_SUBST(LIBCDIO_DEPS) diff --git a/example/C++/OO/Makefile.am b/example/C++/OO/Makefile.am index 07efa6f5..1dd999bf 100644 --- a/example/C++/OO/Makefile.am +++ b/example/C++/OO/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.7 2006/03/06 22:15:35 rocky Exp $ +# $Id: Makefile.am,v 1.8 2006/03/07 10:46:36 rocky Exp $ # # Copyright (C) 2005, 2006 Rocky Bernstein # @@ -41,15 +41,15 @@ eject_DEPENDENCIES = $(LIBCDIO_DEPS) eject_LDADD = $(LIBCDIOPP_LIBS) $(LIBCDIO_LIBS) iso1_SOURCES = iso1.cpp -iso1_LDADD = $(LIBISO966PP0_LIBS) $(LIBISO9660_LIBS) \ +iso1_LDADD = $(LIBISO9660PP_LIBS) $(LIBISO9660_LIBS) \ $(LIBCDIOPP_LIBS) $(LIBICONV) iso2_SOURCES = iso2.cpp -iso2_LDADD = $(LIBISO966PP0_LIBS) $(LIBISO9660_LIBS) \ +iso2_LDADD = $(LIBISO9660PP_LIBS) $(LIBISO9660_LIBS) \ $(LIBCDIOPP_LIBS) $(LIBICONV) iso3_SOURCES = iso3.cpp -iso3_LDADD = $(LIBISO966PP0_LIBS) $(LIBISO9660_LIBS) \ +iso3_LDADD = $(LIBISO9660PP_LIBS) $(LIBISO9660_LIBS) \ $(LIBCDIOPP_LIBS) $(LIBICONV) mmc1_SOURCES = mmc1.cpp diff --git a/include/cdio++/cdio.hpp b/include/cdio++/cdio.hpp index b019dca7..4da522f8 100644 --- a/include/cdio++/cdio.hpp +++ b/include/cdio++/cdio.hpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - $Id: cdio.hpp,v 1.10 2006/03/06 21:54:56 rocky Exp $ + $Id: cdio.hpp,v 1.11 2006/03/07 10:46:36 rocky Exp $ Copyright (C) 2005, 2006 Rocky Bernstein @@ -95,29 +95,7 @@ public: DriverOpNoDriver(void) {driver_return_code = DRIVER_OP_NO_DRIVER;} }; -void possible_throw_device_exception(driver_return_code_t drc) - { - switch (drc) { - case DRIVER_OP_SUCCESS: - return; - case DRIVER_OP_ERROR: - throw DriverOpError(); - case DRIVER_OP_UNSUPPORTED: - throw DriverOpUnsupported(); - case DRIVER_OP_UNINIT: - throw DriverOpUninit(); - case DRIVER_OP_NOT_PERMITTED: - throw DriverOpNotPermitted(); - case DRIVER_OP_BAD_PARAMETER: - throw DriverOpBadParameter(); - case DRIVER_OP_BAD_POINTER: - throw DriverOpBadPointer(); - case DRIVER_OP_NO_DRIVER: - throw DriverOpNoDriver(); - default: - throw DriverOpException(drc); - } - } +void possible_throw_device_exception(driver_return_code_t drc); /** A class relating to CD-Text. Use invalid track number 0 to specify CD-Text for the CD (as opposed to a specific track). @@ -174,8 +152,8 @@ class CdioDevice { public: - CdIo_t *p_cdio; // Make private? If so, subclasses would have to - // use their own. + + CdIo_t *p_cdio; CdioDevice() { diff --git a/include/cdio++/devices.hpp b/include/cdio++/devices.hpp index ac6b6e1f..be7ef202 100644 --- a/include/cdio++/devices.hpp +++ b/include/cdio++/devices.hpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - $Id: devices.hpp,v 1.3 2006/01/25 07:21:52 rocky Exp $ + $Id: devices.hpp,v 1.4 2006/03/07 10:46:36 rocky Exp $ Copyright (C) 2005, 2006 Rocky Bernstein @@ -32,12 +32,8 @@ @param driver_id is the driver to be used or that got used if it was DRIVER_UNKNOWN or DRIVER_DEVICE; If this is NULL, we won't report back the driver used. -v*/ -void closeTray (const char *psz_drive, /*in/out*/ driver_id_t &driver_id) -{ - driver_return_code_t drc = cdio_close_tray (psz_drive, &driver_id); - possible_throw_device_exception(drc); -} +*/ +void closeTray (const char *psz_drive, /*in/out*/ driver_id_t &driver_id); /*! Close media tray in CD drive if there is a routine to do so. @@ -45,11 +41,7 @@ void closeTray (const char *psz_drive, /*in/out*/ driver_id_t &driver_id) @param psz_drive the name of CD-ROM to be closed. If omitted or NULL, we'll scan for a suitable CD-ROM. */ -void closeTray (const char *psz_drive=(const char *)NULL) -{ - driver_id_t driver_id = DRIVER_UNKNOWN; - closeTray(psz_drive, driver_id); -} +void closeTray (const char *psz_drive=(const char *)NULL); /*! Get a string decribing driver_id. @@ -57,23 +49,14 @@ void closeTray (const char *psz_drive=(const char *)NULL) @param driver_id the driver you want the description for @return a sring of driver description */ -const char * -driverDescribe (driver_id_t driver_id) -{ - return cdio_driver_describe(driver_id); -} +const char *driverDescribe (driver_id_t driver_id); /*! Eject media in CD drive if there is a routine to do so. If the CD is ejected, object is destroyed. */ -void -ejectMedia (const char *psz_drive) -{ - driver_return_code_t drc = cdio_eject_media_drive(psz_drive); - possible_throw_device_exception(drc); -} +void ejectMedia (const char *psz_drive); /*! Free device list returned by GetDevices @@ -83,11 +66,7 @@ ejectMedia (const char *psz_drive) @see GetDevices */ -void -freeDeviceList (char * device_list[]) -{ - cdio_free_device_list(device_list); -} +void freeDeviceList (char * device_list[]); /*! Return a string containing the default CD device if none is specified. @@ -96,11 +75,7 @@ freeDeviceList (char * device_list[]) NULL is returned if we couldn't get a default device. */ -char * -getDefaultDevice(/*in/out*/ driver_id_t &driver_id) -{ - return cdio_get_default_device_driver(&driver_id); -} +char * getDefaultDevice(/*in/out*/ driver_id_t &driver_id); /*! Return an array of device names. If you want a specific devices for a driver, give that device. If you want hardware @@ -113,11 +88,7 @@ getDefaultDevice(/*in/out*/ driver_id_t &driver_id) there is no media in it and it is possible for this routine to return NULL even though there may be a hardware CD-ROM. */ -char ** -getDevices(driver_id_t driver_id=DRIVER_DEVICE) -{ - return cdio_get_devices(driver_id); -} +char ** getDevices(driver_id_t driver_id=DRIVER_DEVICE); /*! Like GetDevices above, but we may change the p_driver_id if we were given DRIVER_DEVICE or DRIVER_UNKNOWN. This is because @@ -126,11 +97,7 @@ getDevices(driver_id_t driver_id=DRIVER_DEVICE) things up for libcdio as well. */ -char ** -getDevices (driver_id_t &driver_id) -{ - return cdio_get_devices_ret(&driver_id); -} +char **getDevices (driver_id_t &driver_id); /*! Get an array of device names in search_devices that have at least @@ -149,12 +116,8 @@ getDevices (driver_id_t &driver_id) after dereferencing the the value is NULL. This also means nothing was found. */ -char ** -getDevices(/*in*/ char *ppsz_search_devices[], - cdio_fs_anal_t capabilities, bool b_any=false) -{ - return cdio_get_devices_with_cap(ppsz_search_devices, capabilities, b_any); -} +char ** getDevices(/*in*/ char *ppsz_search_devices[], + cdio_fs_anal_t capabilities, bool b_any=false); /*! Like GetDevices above but we return the driver we found @@ -162,21 +125,12 @@ getDevices(/*in*/ char *ppsz_search_devices[], and then *open* it afterwards. Giving the driver back facilitates this, and speeds things up for libcdio as well. */ -char ** -getDevices(/*in*/ char* ppsz_search_devices[], - cdio_fs_anal_t capabilities, /*out*/ driver_id_t &driver_id, - bool b_any=false) -{ - return cdio_get_devices_with_cap_ret(ppsz_search_devices, capabilities, - b_any, &driver_id); -} +char ** getDevices(/*in*/ char* ppsz_search_devices[], + cdio_fs_anal_t capabilities, /*out*/ driver_id_t &driver_id, + bool b_any=false); -/*! Like cdio_have_xxx but uses an enumeration instead. */ -bool -haveDriver (driver_id_t driver_id) -{ - return cdio_have_driver(driver_id); -} +/*! Return true if we Have driver for driver_id */ +bool haveDriver (driver_id_t driver_id); /*! @@ -186,11 +140,8 @@ Determine if bin_name is the bin file part of a CDRWIN CD disk image. @return the corresponding CUE file if bin_name is a BIN file or NULL if not a BIN file. */ -char * -isBinFile(const char *bin_name) -{ - return cdio_is_binfile(bin_name); -} +char *isBinFile(const char *psz_bin_name); + /*! Determine if cue_name is the cue sheet for a CDRWIN CD disk image. @@ -198,37 +149,7 @@ isBinFile(const char *bin_name) @return corresponding BIN file if cue_name is a CDRWIN cue file or NULL if not a CUE file. */ -char * -isCueFile(const char *cue_name) -{ - return cdio_is_cuefile(cue_name); -} - -/*! - Determine if psg_nrg is a Nero CD disk image. - - @param psz_nrg location of presumed NRG image file. - @return true if psz_nrg is a Nero NRG image or false - if not a NRG image. -*/ -bool -isNero(const char *psz_nrg) -{ - return cdio_is_nrg(psz_nrg); -} - -/*! - Determine if psg_toc is a TOC file for a cdrdao CD disk image. - - @param psz_toc location of presumed TOC image file. - @return true if toc_name is a cdrdao TOC file or false - if not a TOC file. -*/ -bool -isTocFile(const char *psz_toc) -{ - return cdio_is_tocfile(psz_toc); -} +char *isCueFile(const char *psz_cue_name); /*! Determine if psz_source refers to a real hardware CD-ROM. @@ -239,8 +160,23 @@ isTocFile(const char *psz_toc) @return true if psz_source is a device; If false is returned we could have a CD disk image. */ -bool -isDevice(const char *psz_source, driver_id_t driver_id) -{ - return cdio_is_device(psz_source, driver_id); -} +bool isDevice(const char *psz_source, driver_id_t driver_id); + +/*! + Determine if psz_nrg is a Nero CD disk image. + + @param psz_nrg location of presumed NRG image file. + @return true if psz_nrg is a Nero NRG image or false + if not a NRG image. +*/ +bool isNero(const char *psz_nrg); + +/*! + Determine if psz_toc is a TOC file for a cdrdao CD disk image. + + @param psz_toc location of presumed TOC image file. + @return true if toc_name is a cdrdao TOC file or false + if not a TOC file. +*/ +bool isTocFile(const char *psz_toc); + diff --git a/include/cdio++/iso9660.hpp b/include/cdio++/iso9660.hpp index 39e1352e..ba407756 100644 --- a/include/cdio++/iso9660.hpp +++ b/include/cdio++/iso9660.hpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - $Id: iso9660.hpp,v 1.6 2006/03/06 21:54:56 rocky Exp $ + $Id: iso9660.hpp,v 1.7 2006/03/07 10:46:36 rocky Exp $ Copyright (C) 2006 Rocky Bernstein @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/** \file iso966o.hpp +/** \file iso9660.hpp * * \brief C++ class for libcdio: the CD Input and Control * library. Applications use this for anything regarding libcdio. @@ -40,10 +40,79 @@ class ISO9660 public: - class Stat + class PVD // Primary Volume ID { public: - iso9660_stat_t *p_stat; // Make private? + + iso9660_pvd_t pvd; // Make private? + + PVD(iso9660_pvd_t *p_new_pvd) + { + memcpy(&pvd, p_new_pvd, sizeof(pvd)); + }; + + /*! + Return the PVD's application ID. + NULL is returned if there is some problem in getting this. + */ + char * get_application_id(); + + int get_pvd_block_size(); + + /*! + Return the PVD's preparer ID. + NULL is returned if there is some problem in getting this. + */ + char * get_preparer_id(); + + /*! + Return the PVD's publisher ID. + NULL is returned if there is some problem in getting this. + */ + char * get_publisher_id(); + + const char *get_pvd_id(); + + int get_pvd_space_size(); + + uint8_t get_pvd_type(); + + /*! Return the primary volume id version number (of pvd). + If there is an error 0 is returned. + */ + int get_pvd_version(); + + /*! Return the LSN of the root directory for pvd. + If there is an error CDIO_INVALID_LSN is returned. + */ + lsn_t get_root_lsn(); + + /*! + Return the PVD's system ID. + NULL is returned if there is some problem in getting this. + */ + char * get_system_id(); + + /*! + Return the PVD's volume ID. + NULL is returned if there is some problem in getting this. + */ + char * get_volume_id(); + + /*! + Return the PVD's volumeset ID. + NULL is returned if there is some problem in getting this. + */ + char * get_volumeset_id(); + + }; + + class Stat // ISO 9660 file information + { + public: + + iso9660_stat_t *p_stat; + typedef list< ISO9660::Stat *> stat_list_t; Stat(iso9660_stat_t *p_new_stat) { @@ -71,113 +140,68 @@ public: p_stat = NULL; } - }; - class PVD + + class FS : public CdioDevice // ISO 9660 Filesystem on a CD or CD-image { public: - iso9660_pvd_t pvd; // Make private? - - PVD(iso9660_pvd_t *p_new_pvd) - { - memcpy(&pvd, p_new_pvd, sizeof(pvd)); - }; + typedef list< ISO9660::Stat *> stat_list_t; /*! - Return the PVD's application ID. - NULL is returned if there is some problem in getting this. + Given a directory pointer, find the filesystem entry that contains + lsn and return information about it. + + @return Stat * of entry if we found lsn, or NULL otherwise. + Caller must free return value. */ - char * get_application_id() - { - return iso9660_get_application_id(&pvd); - }; - - int get_pvd_block_size() - { - return iso9660_get_pvd_block_size(&pvd); - } - + Stat *find_lsn(lsn_t i_lsn); + /*! - Return the PVD's preparer ID. - NULL is returned if there is some problem in getting this. + Read the Primary Volume Descriptor for a CD. + True is returned if read, and false if there was an error. */ - char * get_preparer_id() - { - return iso9660_get_preparer_id(&pvd); - }; - + bool read_pvd (/*out*/ iso9660_pvd_t *p_pvd); + /*! - Return the PVD's publisher ID. - NULL is returned if there is some problem in getting this. + Read the Super block of an ISO 9660 image. This is the + Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume + Descriptor if (Joliet) extensions are acceptable. */ - char * get_publisher_id() - { - return iso9660_get_publisher_id(&pvd); - }; - - const char *get_pvd_id() - { - return iso9660_get_pvd_id(&pvd); - }; - - int get_pvd_space_size() - { - return iso9660_get_pvd_space_size(&pvd); - }; - - uint8_t get_pvd_type() { - return iso9660_get_pvd_type(&pvd); - }; - - /*! Return the primary volume id version number (of pvd). - If there is an error 0 is returned. + bool read_superblock (iso_extension_mask_t iso_extension_mask); + + /*! Read psz_path (a directory) and return a list of iso9660_stat_t + pointers for the files inside that directory. The caller must free the + returned result. */ - int get_pvd_version() - { - return iso9660_get_pvd_version(&pvd); - } - - /*! Return the LSN of the root directory for pvd. - If there is an error CDIO_INVALID_LSN is returned. - */ - lsn_t get_root_lsn() - { - return iso9660_get_root_lsn(&pvd); - } - + bool readdir (const char psz_path[], bool b_mode2, + stat_list_t& stat_list); + /*! - Return the PVD's system ID. - NULL is returned if there is some problem in getting this. + Return file status for path name psz_path. NULL is returned on + error. + + If translate is true, version numbers in the ISO 9660 name are + dropped, i.e. ;1 is removed and if level 1 ISO-9660 names are + lowercased. + + Mode2 is used only if translate is true and is a hack that + really should go away in libcdio sometime. If set use mode 2 + reading, otherwise use mode 1 reading. + + @return file status object for psz_path. NULL is returned on + error. */ - char * get_system_id() - { - return iso9660_get_system_id(&pvd); - }; - - /*! - Return the PVD's volume ID. - NULL is returned if there is some problem in getting this. - */ - char * get_volume_id() - { - return iso9660_get_volume_id(&pvd); - }; - - /*! - Return the PVD's volumeset ID. - NULL is returned if there is some problem in getting this. - */ - char * get_volumeset_id() - { - return iso9660_get_volumeset_id(&pvd); - }; - + Stat *stat (const char psz_path[], bool b_translate=false, + bool b_mode2=false) ; }; - - class IFS + + class IFS // ISO 9660 filesystem image { public: + + typedef list< ISO9660::Stat *> stat_list_t; + IFS() { p_iso9660=NULL; @@ -196,94 +220,61 @@ public: @return true is unconditionally returned. If there was an error false would be returned. */ - bool - close() - { - iso9660_close(p_iso9660); - p_iso9660 = (iso9660_t *) NULL; - return true; - }; - + bool close(); + /*! Given a directory pointer, find the filesystem entry that contains lsn and return information about it. Returns Stat* of entry if we found lsn, or NULL otherwise. */ - Stat *find_lsn(lsn_t i_lsn) - { - return new Stat(iso9660_ifs_find_lsn(p_iso9660, i_lsn)); - }; + Stat *find_lsn(lsn_t i_lsn); /*! Get the application ID. psz_app_id is set to NULL if there is some problem in getting this and false is returned. */ - bool get_application_id(/*out*/ char * &psz_app_id) - { - return iso9660_ifs_get_application_id(p_iso9660, &psz_app_id); - }; + bool get_application_id(/*out*/ char * &psz_app_id); /*! Return the Joliet level recognized. */ - uint8_t get_joliet_level() - { - return iso9660_ifs_get_joliet_level(p_iso9660); - }; + uint8_t get_joliet_level(); /*! Get the preparer ID. psz_preparer_id is set to NULL if there is some problem in getting this and false is returned. */ - bool get_preparer_id(/*out*/ char * &psz_preparer_id) - { - return iso9660_ifs_get_preparer_id(p_iso9660, &psz_preparer_id); - }; + bool get_preparer_id(/*out*/ char * &psz_preparer_id); /*! Get the publisher ID. psz_publisher_id is set to NULL if there is some problem in getting this and false is returned. */ - bool get_publisher_id(/*out*/ char * &psz_publisher_id) - { - return iso9660_ifs_get_publisher_id(p_iso9660, &psz_publisher_id); - }; + bool get_publisher_id(/*out*/ char * &psz_publisher_id); /*! Get the system ID. psz_system_id is set to NULL if there is some problem in getting this and false is returned. */ - bool get_system_id(/*out*/ char * &psz_system_id) - { - return iso9660_ifs_get_system_id(p_iso9660, &psz_system_id); - }; + bool get_system_id(/*out*/ char * &psz_system_id); /*! Return the volume ID in the PVD. psz_volume_id is set to NULL if there is some problem in getting this and false is returned. */ - bool get_volume_id(/*out*/ char * &psz_volume_id) - { - return iso9660_ifs_get_volume_id(p_iso9660, &psz_volume_id); - }; + bool get_volume_id(/*out*/ char * &psz_volume_id); /*! Return the volumeset ID in the PVD. psz_volumeset_id is set to NULL if there is some problem in getting this and false is returned. */ - bool get_volumeset_id(/*out*/ char * &psz_volumeset_id) - { - return iso9660_ifs_get_volumeset_id(p_iso9660, &psz_volumeset_id); - }; + bool get_volumeset_id(/*out*/ char * &psz_volumeset_id); /*! Return true if ISO 9660 image has extended attrributes (XA). */ - bool is_xa () - { - return iso9660_ifs_is_xa (p_iso9660); - }; + bool is_xa (); /*! Open an ISO 9660 image for reading. Maybe in the future we will have a mode. NULL is returned on error. An open routine should be @@ -298,14 +289,8 @@ public: @see open_fuzzy */ - bool - open(const char *psz_path, - iso_extension_mask_t iso_extension_mask=ISO_EXTENSION_NONE) - { - if (p_iso9660) iso9660_close(p_iso9660); - p_iso9660 = iso9660_open_ext(psz_path, iso_extension_mask); - return NULL != (iso9660_t *) p_iso9660 ; - }; + bool open(const char *psz_path, + iso_extension_mask_t iso_extension_mask=ISO_EXTENSION_NONE); /*! Open an ISO 9660 image for "fuzzy" reading. This means that we will try to guess various internal offset based on internal @@ -318,28 +303,15 @@ public: @see open */ - bool - open_fuzzy (const char *psz_path, - iso_extension_mask_t iso_extension_mask=ISO_EXTENSION_NONE, - uint16_t i_fuzz=20) - { - p_iso9660 = iso9660_open_fuzzy_ext(psz_path, iso_extension_mask, i_fuzz); - //return p_iso9660 != (iso9660_t *) NULL; - return true; - }; + bool open_fuzzy (const char *psz_path, + iso_extension_mask_t iso_extension_mask + =ISO_EXTENSION_NONE, + uint16_t i_fuzz=20); /*! Read the Primary Volume Descriptor for an ISO 9660 image. A PVD object is returned if read, and NULL if there was an error. */ - PVD *read_pvd () - { - iso9660_pvd_t pvd; - bool b_okay = iso9660_ifs_read_pvd (p_iso9660, &pvd); - if (b_okay) { - return new PVD(&pvd); - } - return (PVD *) NULL; - } + PVD *read_pvd (); /*! Read the Super block of an ISO 9660 image but determine framesize @@ -349,14 +321,10 @@ public: @see read_superblock */ - bool - read_superblock (iso_extension_mask_t iso_extension_mask= - ISO_EXTENSION_NONE, - uint16_t i_fuzz=20) - { - return iso9660_ifs_read_superblock (p_iso9660, iso_extension_mask); - }; - + bool read_superblock (iso_extension_mask_t iso_extension_mask + =ISO_EXTENSION_NONE, + uint16_t i_fuzz=20); + /*! Read the Super block of an ISO 9660 image but determine framesize and datastart and a possible additional offset. Generally here we are @@ -366,143 +334,30 @@ public: @see read_superblock */ bool - read_superblock_fuzzy (iso_extension_mask_t iso_extension_mask= - ISO_EXTENSION_NONE, - uint16_t i_fuzz=20) - { - return iso9660_ifs_fuzzy_read_superblock (p_iso9660, iso_extension_mask, - i_fuzz); - }; + read_superblock_fuzzy (iso_extension_mask_t iso_extension_mask + =ISO_EXTENSION_NONE, + uint16_t i_fuzz=20); /*! Read psz_path (a directory) and return a list of iso9660_stat_t pointers for the files inside that directory. The caller must free the returned result. */ - bool - readdir (const char psz_path[], list< ISO9660::Stat *>& stat_list) - { - CdioList_t *p_stat_list = iso9660_ifs_readdir (p_iso9660, psz_path); - - if (p_stat_list) { - CdioListNode_t *p_entnode; - _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)); - } - _cdio_list_free (p_stat_list, false); - return true; - } else { - return false; - } - } + bool readdir (const char psz_path[], stat_list_t& stat_list); /*! Seek to a position and then read n bytes. Size read is returned. */ - long int seek_read (void *ptr, lsn_t start, long int i_size=1) - { - return iso9660_iso_seek_read (p_iso9660, ptr, start, i_size); - }; + long int seek_read (void *ptr, lsn_t start, long int i_size=1); /*! Return file status for pathname. NULL is returned on error. */ - Stat *stat (const char psz_path[], bool b_translate=false) - { - if (b_translate) - return new Stat(iso9660_ifs_stat_translate (p_iso9660, psz_path)); - else - return new Stat(iso9660_ifs_stat (p_iso9660, psz_path)); - } + Stat *stat (const char psz_path[], bool b_translate=false); private: iso9660_t *p_iso9660; }; - class FS : public CdioDevice - { - public: - - /*! - Given a directory pointer, find the filesystem entry that contains - lsn and return information about it. - - @return Stat * of entry if we found lsn, or NULL otherwise. - Caller must free return value. - */ - Stat *find_lsn(lsn_t i_lsn) - { - return new Stat(iso9660_find_fs_lsn(p_cdio, i_lsn)); - } - - /*! - Read the Primary Volume Descriptor for a CD. - True is returned if read, and false if there was an error. - */ - bool read_pvd ( /*out*/ iso9660_pvd_t *p_pvd ) - { - return iso9660_fs_read_pvd ( p_cdio, p_pvd ); - } - - /*! - Read the Super block of an ISO 9660 image. This is the - Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume - Descriptor if (Joliet) extensions are acceptable. - */ - bool read_superblock (iso_extension_mask_t iso_extension_mask) - { - return iso9660_fs_read_superblock (p_cdio, iso_extension_mask); - } - - /*! Read psz_path (a directory) and return a list of iso9660_stat_t - pointers for the files inside that directory. The caller must free the - returned result. - */ - bool readdir (const char psz_path[], bool b_mode2, - list< ISO9660::Stat *>& stat_list) - { - CdioList_t * p_stat_list = iso9660_fs_readdir (p_cdio, psz_path, - b_mode2); - if (p_stat_list) { - CdioListNode_t *p_entnode; - _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)); - } - _cdio_list_free (p_stat_list, false); - return true; - } else { - return false; - } - } - - /*! - Return file status for path name psz_path. NULL is returned on - error. - - If translate is true, version numbers in the ISO 9660 name are - dropped, i.e. ;1 is removed and if level 1 ISO-9660 names are - lowercased. - - Mode2 is used only if translate is true and is a hack that - really should go away in libcdio sometime. If set use mode 2 - reading, otherwise use mode 1 reading. - - @return file status object for psz_path. NULL is returned on - error. - */ - Stat *stat (const char psz_path[], bool b_translate=false, - bool b_mode2=false) - { - if (b_translate) - return new ISO9660::Stat(iso9660_fs_stat_translate (p_cdio, psz_path, - b_mode2)); - else - return new ISO9660::Stat(iso9660_fs_stat (p_cdio, psz_path)); - } - }; }; #endif /* __ISO9660_HPP__ */ diff --git a/lib/cdio++/Makefile.am b/lib/cdio++/Makefile.am index 1fad3976..6bf54325 100644 --- a/lib/cdio++/Makefile.am +++ b/lib/cdio++/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.4 2006/03/06 04:48:38 rocky Exp $ +# $Id: Makefile.am,v 1.5 2006/03/07 10:46:36 rocky Exp $ # # Copyright (C) 2005, 2006 Rocky Bernstein # @@ -48,7 +48,7 @@ libcdiopp_la_CURRENT := 0 libcdiopp_la_REVISION := 0 libcdiopp_la_AGE := 0 -libcdiopp_sources = cdio_stub.cpp +libcdiopp_sources = cdio.cpp devices.cpp libcdio___la_SOURCES = $(libcdiopp_sources) libcdio___la_ldflags = -version-info $(libcdiopp_la_CURRENT):$(libcdiopp_la_REVISION):$(libcdiopp_la_AGE) @@ -57,7 +57,7 @@ libiso9660pp_la_CURRENT := 0 libiso9660pp_la_REVISION := 0 libiso9660pp_la_AGE := 0 -libiso9660pp_sources = iso9660_stub.cpp +libiso9660pp_sources = iso9660.cpp libiso9660___la_SOURCES = $(libiso9660pp_sources) libiso9660___la_ldflags = -version-info $(libiso9660pp_la_CURRENT):$(libiso9660pp_la_REVISION):$(libiso9660pp_la_AGE) diff --git a/lib/cdio++/cdio.cpp b/lib/cdio++/cdio.cpp new file mode 100644 index 00000000..652f2360 --- /dev/null +++ b/lib/cdio++/cdio.cpp @@ -0,0 +1,45 @@ +/* -*- C++ -*- + $Id: cdio.cpp,v 1.1 2006/03/07 10:46:37 rocky Exp $ + + Copyright (C) 2006 Rocky Bernstein + + 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 +*/ +#include +#include + +void possible_throw_device_exception(driver_return_code_t drc) + { + switch (drc) { + case DRIVER_OP_SUCCESS: + return; + case DRIVER_OP_ERROR: + throw DriverOpError(); + case DRIVER_OP_UNSUPPORTED: + throw DriverOpUnsupported(); + case DRIVER_OP_UNINIT: + throw DriverOpUninit(); + case DRIVER_OP_NOT_PERMITTED: + throw DriverOpNotPermitted(); + case DRIVER_OP_BAD_PARAMETER: + throw DriverOpBadParameter(); + case DRIVER_OP_BAD_POINTER: + throw DriverOpBadPointer(); + case DRIVER_OP_NO_DRIVER: + throw DriverOpNoDriver(); + default: + throw DriverOpException(drc); + } + } diff --git a/lib/cdio++/cdio_stub.cpp b/lib/cdio++/cdio_stub.cpp deleted file mode 100644 index aeffee0d..00000000 --- a/lib/cdio++/cdio_stub.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include -#include - diff --git a/lib/cdio++/iso9660.cpp b/lib/cdio++/iso9660.cpp new file mode 100644 index 00000000..a288ec5f --- /dev/null +++ b/lib/cdio++/iso9660.cpp @@ -0,0 +1,438 @@ +/* -*- C++ -*- + $Id: iso9660.cpp,v 1.1 2006/03/07 10:46:37 rocky Exp $ + + Copyright (C) 2006 Rocky Bernstein + + 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 +*/ +#include + +/*! + Given a directory pointer, find the filesystem entry that contains + lsn and return information about it. + + @return Stat * of entry if we found lsn, or NULL otherwise. + Caller must free return value. +*/ +ISO9660::Stat * +ISO9660::FS::find_lsn(lsn_t i_lsn) +{ + return new Stat(iso9660_find_fs_lsn(p_cdio, i_lsn)); +} + +/*! + Read the Primary Volume Descriptor for a CD. + True is returned if read, and false if there was an error. +*/ +bool +ISO9660::FS::read_pvd ( /*out*/ iso9660_pvd_t *p_pvd ) +{ + return iso9660_fs_read_pvd ( p_cdio, p_pvd ); +} + +/*! + Read the Super block of an ISO 9660 image. This is the + Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume + Descriptor if (Joliet) extensions are acceptable. +*/ +bool +ISO9660::FS::read_superblock (iso_extension_mask_t iso_extension_mask) +{ + return iso9660_fs_read_superblock (p_cdio, iso_extension_mask); +} + +/*! Read psz_path (a directory) and return a list of iso9660_stat_t + pointers for the files inside that directory. The caller must free the + returned result. +*/ +bool +ISO9660::FS::readdir (const char psz_path[], bool b_mode2, + stat_list_t& stat_list) +{ + CdioList_t * p_stat_list = iso9660_fs_readdir (p_cdio, psz_path, + b_mode2); + if (p_stat_list) { + CdioListNode_t *p_entnode; + _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)); + } + _cdio_list_free (p_stat_list, false); + return true; + } else { + return false; + } +} + +/*! + Return file status for path name psz_path. NULL is returned on + error. + + If translate is true, version numbers in the ISO 9660 name are + dropped, i.e. ;1 is removed and if level 1 ISO-9660 names are + lowercased. + + Mode2 is used only if translate is true and is a hack that + really should go away in libcdio sometime. If set use mode 2 + reading, otherwise use mode 1 reading. + + @return file status object for psz_path. NULL is returned on + error. +*/ +ISO9660::Stat * +ISO9660::FS::stat (const char psz_path[], bool b_translate, bool b_mode2) +{ + if (b_translate) + return new ISO9660::Stat(iso9660_fs_stat_translate (p_cdio, psz_path, + b_mode2)); + else + return new ISO9660::Stat(iso9660_fs_stat (p_cdio, psz_path)); +} + +/*! Close previously opened ISO 9660 image and free resources + associated with the image. Call this when done using using an ISO + 9660 image. + + @return true is unconditionally returned. If there was an error + false would be returned. +*/ +bool +ISO9660::IFS::close() +{ + iso9660_close(p_iso9660); + p_iso9660 = (iso9660_t *) NULL; + return true; +} + +/*! + Given a directory pointer, find the filesystem entry that contains + lsn and return information about it. + + Returns Stat* of entry if we found lsn, or NULL otherwise. +*/ +ISO9660::Stat * +ISO9660::IFS::find_lsn(lsn_t i_lsn) +{ + return new Stat(iso9660_ifs_find_lsn(p_iso9660, i_lsn)); +} + +/*! + Get the application ID. psz_app_id is set to NULL if there + is some problem in getting this and false is returned. +*/ +bool +ISO9660::IFS::get_application_id(/*out*/ char * &psz_app_id) +{ + return iso9660_ifs_get_application_id(p_iso9660, &psz_app_id); +} + +/*! + Return the Joliet level recognized. +*/ +uint8_t +ISO9660::IFS::get_joliet_level() +{ + return iso9660_ifs_get_joliet_level(p_iso9660); +} + +/*! + Get the preparer ID. psz_preparer_id is set to NULL if there + is some problem in getting this and false is returned. +*/ +bool +ISO9660::IFS::get_preparer_id(/*out*/ char * &psz_preparer_id) +{ + return iso9660_ifs_get_preparer_id(p_iso9660, &psz_preparer_id); +} + +/*! + Get the publisher ID. psz_publisher_id is set to NULL if there + is some problem in getting this and false is returned. +*/ +bool +ISO9660::IFS::get_publisher_id(/*out*/ char * &psz_publisher_id) +{ + return iso9660_ifs_get_publisher_id(p_iso9660, &psz_publisher_id); +} + +/*! + Get the system ID. psz_system_id is set to NULL if there + is some problem in getting this and false is returned. +*/ +bool +ISO9660::IFS::get_system_id(/*out*/ char * &psz_system_id) +{ + return iso9660_ifs_get_system_id(p_iso9660, &psz_system_id); +} + +/*! Return the volume ID in the PVD. psz_volume_id is set to + NULL if there is some problem in getting this and false is + returned. +*/ +bool +ISO9660::IFS::get_volume_id(/*out*/ char * &psz_volume_id) +{ + return iso9660_ifs_get_volume_id(p_iso9660, &psz_volume_id); +} + +/*! Return the volumeset ID in the PVD. psz_volumeset_id is set to + NULL if there is some problem in getting this and false is + returned. +*/ +bool +ISO9660::IFS::get_volumeset_id(/*out*/ char * &psz_volumeset_id) +{ + return iso9660_ifs_get_volumeset_id(p_iso9660, &psz_volumeset_id); +} + +/*! + Return true if ISO 9660 image has extended attrributes (XA). +*/ +bool +ISO9660::IFS::is_xa () +{ + return iso9660_ifs_is_xa (p_iso9660); +} + +/*! Open an ISO 9660 image for reading. Maybe in the future we will + have a mode. NULL is returned on error. An open routine should be + called before using any read routine. If device object was + previously opened it is closed first. + + @param psz_path location of ISO 9660 image + @param iso_extension_mask the kinds of ISO 9660 extensions will be + considered on access. + + @return true if open succeeded or false if error. + + @see open_fuzzy +*/ +bool +ISO9660::IFS::open(const char *psz_path, + iso_extension_mask_t iso_extension_mask) +{ + if (p_iso9660) iso9660_close(p_iso9660); + p_iso9660 = iso9660_open_ext(psz_path, iso_extension_mask); + return NULL != (iso9660_t *) p_iso9660 ; +} + +/*! Open an ISO 9660 image for "fuzzy" reading. This means that we + will try to guess various internal offset based on internal + checks. This may be useful when trying to read an ISO 9660 image + contained in a file format that libiso9660 doesn't know natively + (or knows imperfectly.) + + Maybe in the future we will have a mode. NULL is returned on + error. + + @see open +*/ +bool +ISO9660::IFS::open_fuzzy (const char *psz_path, + iso_extension_mask_t iso_extension_mask, + uint16_t i_fuzz) +{ + p_iso9660 = iso9660_open_fuzzy_ext(psz_path, iso_extension_mask, i_fuzz); + //return p_iso9660 != (iso9660_t *) NULL; + return true; +} + +/*! Read the Primary Volume Descriptor for an ISO 9660 image. A + PVD object is returned if read, and NULL if there was an error. +*/ +ISO9660::PVD * +ISO9660::IFS::read_pvd () +{ + iso9660_pvd_t pvd; + bool b_okay = iso9660_ifs_read_pvd (p_iso9660, &pvd); + if (b_okay) { + return new PVD(&pvd); + } + return (PVD *) NULL; +} + +/*! + Read the Super block of an ISO 9660 image but determine framesize + and datastart and a possible additional offset. Generally here we are + not reading an ISO 9660 image but a CD-Image which contains an ISO 9660 + filesystem. + + @see read_superblock +*/ +bool +ISO9660::IFS::read_superblock (iso_extension_mask_t iso_extension_mask, + uint16_t i_fuzz) +{ + return iso9660_ifs_read_superblock (p_iso9660, iso_extension_mask); +} + +/*! + Read the Super block of an ISO 9660 image but determine framesize + and datastart and a possible additional offset. Generally here we are + not reading an ISO 9660 image but a CD-Image which contains an ISO 9660 + filesystem. + + @see read_superblock +*/ +bool +ISO9660::IFS::read_superblock_fuzzy (iso_extension_mask_t iso_extension_mask, + uint16_t i_fuzz) +{ + return iso9660_ifs_fuzzy_read_superblock (p_iso9660, iso_extension_mask, + i_fuzz); +} + +/*! Read psz_path (a directory) and return a list of iso9660_stat_t + pointers for the files inside that directory. The caller must free + the returned result. +*/ +bool +ISO9660::IFS::readdir (const char psz_path[], + stat_list_t& stat_list) +{ + CdioList_t *p_stat_list = iso9660_ifs_readdir (p_iso9660, psz_path); + + if (p_stat_list) { + CdioListNode_t *p_entnode; + _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)); + } + _cdio_list_free (p_stat_list, false); + return true; + } else { + return false; + } +} + +/*! + Seek to a position and then read n bytes. Size read is returned. +*/ +long int +ISO9660::IFS::seek_read (void *ptr, lsn_t start, long int i_size) +{ + return iso9660_iso_seek_read (p_iso9660, ptr, start, i_size); +} + +/*! + Return file status for pathname. NULL is returned on error. +*/ +ISO9660::Stat * +ISO9660::IFS::stat (const char psz_path[], bool b_translate) +{ + if (b_translate) + return new Stat(iso9660_ifs_stat_translate (p_iso9660, psz_path)); + else + return new Stat(iso9660_ifs_stat (p_iso9660, psz_path)); +} + +char * +ISO9660::PVD::get_application_id() +{ + return iso9660_get_application_id(&pvd); +} + +int +ISO9660::PVD::get_pvd_block_size() +{ + return iso9660_get_pvd_block_size(&pvd); +} + +/*! + Return the PVD's preparer ID. + NULL is returned if there is some problem in getting this. +*/ +char * +ISO9660::PVD::get_preparer_id() +{ + return iso9660_get_preparer_id(&pvd); +} + +/*! + Return the PVD's publisher ID. + NULL is returned if there is some problem in getting this. +*/ +char * +ISO9660::PVD::get_publisher_id() +{ + return iso9660_get_publisher_id(&pvd); +} + +const char * +ISO9660::PVD::get_pvd_id() +{ + return iso9660_get_pvd_id(&pvd); +} + +int +ISO9660::PVD::get_pvd_space_size() +{ + return iso9660_get_pvd_space_size(&pvd); +} + +uint8_t +ISO9660::PVD::get_pvd_type() { + return iso9660_get_pvd_type(&pvd); +} + +/*! Return the primary volume id version number (of pvd). + If there is an error 0 is returned. +*/ +int +ISO9660::PVD::get_pvd_version() +{ + return iso9660_get_pvd_version(&pvd); +} + +/*! Return the LSN of the root directory for pvd. + If there is an error CDIO_INVALID_LSN is returned. +*/ +lsn_t +ISO9660::PVD::get_root_lsn() +{ + return iso9660_get_root_lsn(&pvd); +} + +/*! + Return the PVD's system ID. + NULL is returned if there is some problem in getting this. +*/ +char * +ISO9660::PVD::get_system_id() +{ + return iso9660_get_system_id(&pvd); +} + +/*! + Return the PVD's volume ID. + NULL is returned if there is some problem in getting this. +*/ +char * +ISO9660::PVD::get_volume_id() +{ + return iso9660_get_volume_id(&pvd); +} + +/*! + Return the PVD's volumeset ID. + NULL is returned if there is some problem in getting this. +*/ +char * +ISO9660::PVD::get_volumeset_id() +{ + return iso9660_get_volumeset_id(&pvd); +} diff --git a/lib/cdio++/iso9660_stub.cpp b/lib/cdio++/iso9660_stub.cpp deleted file mode 100644 index 51eb462a..00000000 --- a/lib/cdio++/iso9660_stub.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include -#include -