2006-03-05 06:52:15 +00:00
|
|
|
/* -*- C++ -*-
|
2006-03-07 10:46:36 +00:00
|
|
|
$Id: iso9660.hpp,v 1.7 2006/03/07 10:46:36 rocky Exp $
|
2006-03-05 06:52:15 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
|
|
2006-03-07 10:46:36 +00:00
|
|
|
/** \file iso9660.hpp
|
2006-03-05 06:52:15 +00:00
|
|
|
*
|
|
|
|
|
* \brief C++ class for libcdio: the CD Input and Control
|
|
|
|
|
* library. Applications use this for anything regarding libcdio.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __ISO9660_HPP__
|
|
|
|
|
#define __ISO9660_HPP__
|
|
|
|
|
|
|
|
|
|
#include <cdio/iso9660.h>
|
2006-03-06 21:54:56 +00:00
|
|
|
#include <cdio++/cdio.hpp>
|
2006-03-05 08:31:03 +00:00
|
|
|
#include <string.h>
|
2006-03-06 01:34:22 +00:00
|
|
|
#include <list> // list class library
|
2006-03-06 04:48:37 +00:00
|
|
|
using namespace std;
|
2006-03-05 06:52:15 +00:00
|
|
|
|
|
|
|
|
/** ISO 9660 class.
|
|
|
|
|
*/
|
|
|
|
|
class ISO9660
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2006-03-07 10:46:36 +00:00
|
|
|
class PVD // Primary Volume ID
|
2006-03-05 08:31:03 +00:00
|
|
|
{
|
2006-03-06 01:34:22 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
iso9660_pvd_t pvd; // Make private?
|
|
|
|
|
|
|
|
|
|
PVD(iso9660_pvd_t *p_new_pvd)
|
2006-03-05 08:31:03 +00:00
|
|
|
{
|
2006-03-06 01:34:22 +00:00
|
|
|
memcpy(&pvd, p_new_pvd, sizeof(pvd));
|
2006-03-05 08:31:03 +00:00
|
|
|
};
|
|
|
|
|
|
2006-03-06 01:34:22 +00:00
|
|
|
/*!
|
|
|
|
|
Return the PVD's application ID.
|
|
|
|
|
NULL is returned if there is some problem in getting this.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
char * get_application_id();
|
2006-03-06 01:34:22 +00:00
|
|
|
|
2006-03-07 10:46:36 +00:00
|
|
|
int get_pvd_block_size();
|
2006-03-06 01:34:22 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Return the PVD's preparer ID.
|
|
|
|
|
NULL is returned if there is some problem in getting this.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
char * get_preparer_id();
|
2006-03-06 01:34:22 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Return the PVD's publisher ID.
|
|
|
|
|
NULL is returned if there is some problem in getting this.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
char * get_publisher_id();
|
2006-03-06 01:34:22 +00:00
|
|
|
|
2006-03-07 10:46:36 +00:00
|
|
|
const char *get_pvd_id();
|
2006-03-06 01:34:22 +00:00
|
|
|
|
2006-03-07 10:46:36 +00:00
|
|
|
int get_pvd_space_size();
|
2006-03-06 01:34:22 +00:00
|
|
|
|
2006-03-07 10:46:36 +00:00
|
|
|
uint8_t get_pvd_type();
|
2006-03-06 01:34:22 +00:00
|
|
|
|
|
|
|
|
/*! Return the primary volume id version number (of pvd).
|
|
|
|
|
If there is an error 0 is returned.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
int get_pvd_version();
|
2006-03-06 01:34:22 +00:00
|
|
|
|
|
|
|
|
/*! Return the LSN of the root directory for pvd.
|
|
|
|
|
If there is an error CDIO_INVALID_LSN is returned.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
lsn_t get_root_lsn();
|
2006-03-06 01:34:22 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Return the PVD's system ID.
|
|
|
|
|
NULL is returned if there is some problem in getting this.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
char * get_system_id();
|
2006-03-06 01:34:22 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Return the PVD's volume ID.
|
|
|
|
|
NULL is returned if there is some problem in getting this.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
char * get_volume_id();
|
2006-03-06 01:34:22 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Return the PVD's volumeset ID.
|
|
|
|
|
NULL is returned if there is some problem in getting this.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
char * get_volumeset_id();
|
2006-03-06 01:34:22 +00:00
|
|
|
|
2006-03-05 08:31:03 +00:00
|
|
|
};
|
2006-03-06 01:34:22 +00:00
|
|
|
|
2006-03-07 10:46:36 +00:00
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
p_stat = p_new_stat;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Stat(const Stat& copy_in)
|
|
|
|
|
{
|
|
|
|
|
free(p_stat);
|
|
|
|
|
p_stat = (iso9660_stat_t *)
|
|
|
|
|
calloc( 1, sizeof(iso9660_stat_t)
|
|
|
|
|
+ strlen(copy_in.p_stat->filename)+1 );
|
|
|
|
|
p_stat = copy_in.p_stat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Stat& operator= (const Stat& right)
|
|
|
|
|
{
|
|
|
|
|
free(p_stat);
|
|
|
|
|
this->p_stat = right.p_stat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~Stat()
|
|
|
|
|
{
|
|
|
|
|
free(p_stat);
|
|
|
|
|
p_stat = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class FS : public CdioDevice // ISO 9660 Filesystem on a CD or CD-image
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
typedef list< ISO9660::Stat *> stat_list_t;
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
/*! 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,
|
|
|
|
|
stat_list_t& stat_list);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
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) ;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class IFS // ISO 9660 filesystem image
|
2006-03-05 08:31:03 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2006-03-07 10:46:36 +00:00
|
|
|
|
|
|
|
|
typedef list< ISO9660::Stat *> stat_list_t;
|
|
|
|
|
|
2006-03-05 06:52:15 +00:00
|
|
|
IFS()
|
|
|
|
|
{
|
|
|
|
|
p_iso9660=NULL;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
~IFS()
|
|
|
|
|
{
|
|
|
|
|
iso9660_close(p_iso9660);
|
|
|
|
|
p_iso9660 = (iso9660_t *) NULL;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*! 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.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
bool close();
|
|
|
|
|
|
2006-03-05 08:31:03 +00:00
|
|
|
/*!
|
|
|
|
|
Given a directory pointer, find the filesystem entry that contains
|
|
|
|
|
lsn and return information about it.
|
|
|
|
|
|
2006-03-06 21:54:56 +00:00
|
|
|
Returns Stat* of entry if we found lsn, or NULL otherwise.
|
2006-03-05 08:31:03 +00:00
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
Stat *find_lsn(lsn_t i_lsn);
|
2006-03-05 08:31:03 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Get the application ID. psz_app_id is set to NULL if there
|
|
|
|
|
is some problem in getting this and false is returned.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
bool get_application_id(/*out*/ char * &psz_app_id);
|
2006-03-05 08:31:03 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Return the Joliet level recognized.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
uint8_t get_joliet_level();
|
2006-03-05 08:31:03 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Get the preparer ID. psz_preparer_id is set to NULL if there
|
|
|
|
|
is some problem in getting this and false is returned.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
bool get_preparer_id(/*out*/ char * &psz_preparer_id);
|
2006-03-05 08:31:03 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Get the publisher ID. psz_publisher_id is set to NULL if there
|
|
|
|
|
is some problem in getting this and false is returned.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
bool get_publisher_id(/*out*/ char * &psz_publisher_id);
|
2006-03-05 08:31:03 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Get the system ID. psz_system_id is set to NULL if there
|
|
|
|
|
is some problem in getting this and false is returned.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
bool get_system_id(/*out*/ char * &psz_system_id);
|
2006-03-05 08:31:03 +00:00
|
|
|
|
|
|
|
|
/*! 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.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
bool get_volume_id(/*out*/ char * &psz_volume_id);
|
2006-03-05 08:31:03 +00:00
|
|
|
|
|
|
|
|
/*! 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.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
bool get_volumeset_id(/*out*/ char * &psz_volumeset_id);
|
2006-03-05 08:31:03 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Return true if ISO 9660 image has extended attrributes (XA).
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
bool is_xa ();
|
2006-03-05 08:31:03 +00:00
|
|
|
|
2006-03-05 06:52:15 +00:00
|
|
|
/*! 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
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
bool open(const char *psz_path,
|
|
|
|
|
iso_extension_mask_t iso_extension_mask=ISO_EXTENSION_NONE);
|
2006-03-05 06:52:15 +00:00
|
|
|
|
|
|
|
|
/*! 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
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
bool open_fuzzy (const char *psz_path,
|
|
|
|
|
iso_extension_mask_t iso_extension_mask
|
|
|
|
|
=ISO_EXTENSION_NONE,
|
|
|
|
|
uint16_t i_fuzz=20);
|
2006-03-05 06:52:15 +00:00
|
|
|
|
2006-03-06 01:34:22 +00:00
|
|
|
/*! Read the Primary Volume Descriptor for an ISO 9660 image. A
|
|
|
|
|
PVD object is returned if read, and NULL if there was an error.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
PVD *read_pvd ();
|
2006-03-06 01:34:22 +00:00
|
|
|
|
2006-03-05 06:52:15 +00:00
|
|
|
/*!
|
|
|
|
|
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.
|
2006-03-05 08:31:03 +00:00
|
|
|
|
|
|
|
|
@see read_superblock
|
2006-03-05 06:52:15 +00:00
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
bool read_superblock (iso_extension_mask_t iso_extension_mask
|
|
|
|
|
=ISO_EXTENSION_NONE,
|
|
|
|
|
uint16_t i_fuzz=20);
|
|
|
|
|
|
2006-03-05 08:31:03 +00:00
|
|
|
/*!
|
|
|
|
|
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
|
2006-03-07 10:46:36 +00:00
|
|
|
read_superblock_fuzzy (iso_extension_mask_t iso_extension_mask
|
|
|
|
|
=ISO_EXTENSION_NONE,
|
|
|
|
|
uint16_t i_fuzz=20);
|
2006-03-06 01:34:22 +00:00
|
|
|
|
|
|
|
|
/*! 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.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
bool readdir (const char psz_path[], stat_list_t& stat_list);
|
2006-03-06 01:34:22 +00:00
|
|
|
|
2006-03-05 06:52:15 +00:00
|
|
|
/*!
|
|
|
|
|
Seek to a position and then read n bytes. Size read is returned.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
long int seek_read (void *ptr, lsn_t start, long int i_size=1);
|
2006-03-05 06:52:15 +00:00
|
|
|
|
2006-03-05 08:31:03 +00:00
|
|
|
/*!
|
|
|
|
|
Return file status for pathname. NULL is returned on error.
|
|
|
|
|
*/
|
2006-03-07 10:46:36 +00:00
|
|
|
Stat *stat (const char psz_path[], bool b_translate=false);
|
2006-03-05 06:52:15 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
iso9660_t *p_iso9660;
|
|
|
|
|
};
|
2006-03-05 08:31:03 +00:00
|
|
|
|
2006-03-06 21:54:56 +00:00
|
|
|
};
|
2006-03-05 06:52:15 +00:00
|
|
|
|
|
|
|
|
#endif /* __ISO9660_HPP__ */
|