First commit after CVS conversion. Should be just administrative changes.

This commit is contained in:
R. Bernstein
2008-11-29 00:56:26 -05:00
parent 4ea407f746
commit 95f087cdc3
413 changed files with 86786 additions and 86 deletions

3
lib/cdio++/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/.deps
/Makefile
/Makefile.in

65
lib/cdio++/Makefile.am Normal file
View File

@@ -0,0 +1,65 @@
# $Id: Makefile.am,v 1.11 2008/10/29 09:53:00 rocky Exp $
#
# Copyright (C) 2005, 2006, 2007, 2008 Rocky Bernstein <rocky@gnu.org>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
########################################################
# Things to make the libcdio++ library
########################################################
#
# From libtool documentation amended with guidance from N. Boullis:
#
# 1. Start with version information of `0:0:0' for each libtool library.
#
# 2. It is probably not a good idea to update the version information
# several times between public releases, but rather once per public
# release. (This seems to be more an aesthetic consideration than
# a hard technical one.)
#
# 3. If the library source code has changed at all since the last
# update, then increment REVISION (`C:R:A' becomes `C:R+1:A').
#
# 4. If any interfaces have been added, removed, or changed since the
# last update, increment CURRENT, and set REVISION to 0.
#
# 5. If any interfaces have been added since the last public release,
# then increment AGE.
#
# 6. If any interfaces have been removed or changed since the last
# public release, then set AGE to 0. A changed interface means an
# incompatibility with previous versions.
lib_LTLIBRARIES = libiso9660++.la libcdio++.la
libcdiopp_la_CURRENT = 0
libcdiopp_la_REVISION = 2
libcdiopp_la_AGE = 0
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) @LT_NO_UNDEFINED@
libiso9660pp_la_CURRENT = 0
libiso9660pp_la_REVISION = 0
libiso9660pp_la_AGE = 0
libiso9660pp_sources = iso9660.cpp
libiso9660___la_SOURCES = $(libiso9660pp_sources)
libiso9660___la_LIBADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS)
libiso9660___la_ldflags = -version-info $(libiso9660pp_la_CURRENT):$(libiso9660pp_la_REVISION):$(libiso9660pp_la_AGE) @LT_NO_UNDEFINED@
INCLUDES = -I$(top_srcdir)/include/ -I$(top_builddir)/include

44
lib/cdio++/cdio.cpp Normal file
View File

@@ -0,0 +1,44 @@
/* -*- C++ -*-
$Id: cdio.cpp,v 1.2 2008/04/20 13:44:31 karl Exp $
Copyright (C) 2006, 2008 Rocky Bernstein <rocky@gnu.org>
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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include <sys/types.h>
#include <cdio++/cdio.hpp>
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);
}
}

244
lib/cdio++/devices.cpp Normal file
View File

@@ -0,0 +1,244 @@
/* -*- C++ -*-
$Id: devices.cpp,v 1.3 2008/04/20 13:44:31 karl Exp $
Copyright (C) 2006, 2008 Rocky Bernstein <rocky@gnu.org>
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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <cdio/cdio.h>
#include <cdio++/cdio.hpp>
/*!
Close media tray in CD drive if there is a routine to do so.
@param psz_drive the name of CD-ROM to be closed.
@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.
*/
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);
}
/*!
Close media tray in CD drive if there is a routine to do so.
@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)
{
driver_id_t driver_id = DRIVER_UNKNOWN;
closeTray(psz_drive, driver_id);
}
/*!
Get a string decribing driver_id.
@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);
}
/*!
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);
}
/*!
Free device list returned by GetDevices
@param device_list list returned by GetDevices
@see GetDevices
*/
void
freeDeviceList (char * device_list[])
{
cdio_free_device_list(device_list);
}
/*!
Return a string containing the default CD device if none is specified.
if p_driver_id is DRIVER_UNKNOWN or DRIVER_DEVICE
then find a suitable one set the default device for that.
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);
}
/*! Return an array of device names. If you want a specific
devices for a driver, give that device. If you want hardware
devices, give DRIVER_DEVICE and if you want all possible devices,
image drivers and hardware drivers give DRIVER_UNKNOWN.
NULL is returned if we couldn't return a list of devices.
In some situations of drivers or OS's we can't find a CD device if
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)
{
return cdio_get_devices(driver_id);
}
/*! Like GetDevices above, but we may change the p_driver_id if we
were given DRIVER_DEVICE or DRIVER_UNKNOWN. This is because
often one wants to get a drive name and then *open* it
afterwards. Giving the driver back facilitates this, and speeds
things up for libcdio as well.
*/
char **
getDevices (driver_id_t &driver_id)
{
return cdio_get_devices_ret(&driver_id);
}
/*!
Get an array of device names in search_devices that have at least
the capabilities listed by the capabities parameter. If
search_devices is NULL, then we'll search all possible CD drives.
If "b_any" is set false then every capability listed in the
extended portion of capabilities (i.e. not the basic filesystem)
must be satisified. If "any" is set true, then if any of the
capabilities matches, we call that a success.
To find a CD-drive of any type, use the mask CDIO_FS_MATCH_ALL.
@return the array of device names or NULL if we couldn't get a
default device. It is also possible to return a non NULL but
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)
{
return cdio_get_devices_with_cap(ppsz_search_devices, capabilities, b_any);
}
/*!
Like GetDevices above but we return the driver we found
as well. This is because often one wants to search for kind of drive
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)
{
return cdio_get_devices_with_cap_ret(ppsz_search_devices, capabilities,
b_any, &driver_id);
}
/*! Return true if we Have driver for driver_id */
bool
haveDriver (driver_id_t driver_id)
{
return cdio_have_driver(driver_id);
}
/*!
Determine if bin_name is the bin file part of a CDRWIN CD disk image.
@param bin_name location of presumed CDRWIN bin image file.
@return the corresponding CUE file if bin_name is a BIN file or
NULL if not a BIN file.
*/
char *isBinFile(const char *psz_bin_name)
{
return cdio_is_binfile(psz_bin_name);
}
/*!
Determine if cue_name is the cue sheet for a CDRWIN CD disk image.
@return corresponding BIN file if cue_name is a CDRWIN cue file or
NULL if not a CUE file.
*/
char *
isCueFile(const char *psz_cue_name)
{
return cdio_is_cuefile(psz_cue_name);
}
/*!
Determine if psz_source refers to a real hardware CD-ROM.
@param psz_source location name of object
@param driver_id driver for reading object. Use DRIVER_UNKNOWN if you
don't know what driver to use.
@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);
}
/*!
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)
{
return cdio_is_nrg(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)
{
return cdio_is_tocfile(psz_toc);
}

295
lib/cdio++/iso9660.cpp Normal file
View File

@@ -0,0 +1,295 @@
/* -*- C++ -*-
$Id: iso9660.cpp,v 1.5 2008/04/20 13:44:31 karl Exp $
Copyright (C) 2006, 2008 Rocky Bernstein <rocky@gnu.org>
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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <cdio++/iso9660.hpp>
/*!
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.
*/
ISO9660::PVD *
ISO9660::FS::read_pvd ()
{
iso9660_pvd_t pvd;
bool b_okay = iso9660_fs_read_pvd (p_cdio, &pvd);
if (b_okay) {
return new PVD(&pvd);
}
return (PVD *) NULL;
}
/*!
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[], stat_vector_t& stat_vector,
bool b_mode2)
{
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_vector.push_back(new ISO9660::Stat(p_statbuf));
}
_cdio_list_free (p_stat_list, false);
return true;
} else {
return false;
}
}
/*! 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));
}
/*!
Return the Joliet level recognized.
*/
uint8_t
ISO9660::IFS::get_joliet_level()
{
return iso9660_ifs_get_joliet_level(p_iso9660);
}
/*!
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 "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);
}
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);
}