Move code from devices.hpp and iso9660.hpp headers into external files -
cdio.cpp, device.cpp, iso9660.cpp configure.ac, C++/OO/Makefile.am: Found some bugs libraries acces in doing the above move.
This commit is contained in:
@@ -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 <rocky@panix.com>
|
||||
|
||||
@@ -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__ */
|
||||
|
||||
Reference in New Issue
Block a user