"Fossies" - the Fresh Open Source Software Archive

Member "libcdio-2.1.0/lib/cdio++/iso9660.cpp" (12 Aug 2018, 7127 Bytes) of package /linux/privat/libcdio-2.1.0.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "iso9660.cpp" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.0.0_vs_1.1.0.

    1 /* -*- C++ -*-
    2   Copyright (C) 2006, 2008, 2011, 2017 Rocky Bernstein <rocky@gnu.org>
    3 
    4   This program is free software: you can redistribute it and/or modify
    5   it under the terms of the GNU General Public License as published by
    6   the Free Software Foundation, either version 3 of the License, or
    7   (at your option) any later version.
    8 
    9   This program is distributed in the hope that it will be useful,
   10   but WITHOUT ANY WARRANTY; without even the implied warranty of
   11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12   GNU General Public License for more details.
   13 
   14   You should have received a copy of the GNU General Public License
   15   along with this program.  If not, see <http://www.gnu.org/licenses/>.
   16 */
   17 
   18 #ifdef HAVE_CONFIG_H
   19 # include "config.h"
   20 # define __CDIO_CONFIG_H__ 1
   21 #endif
   22 
   23 #ifdef HAVE_SYS_TYPES_H
   24 #include <sys/types.h>
   25 #endif
   26 
   27 #include <cdio++/iso9660.hpp>
   28 
   29 /*!
   30   Given a directory pointer, find the filesystem entry that contains
   31   lsn and return information about it.
   32 
   33   @return Stat * of entry if we found lsn, or NULL otherwise.
   34   Caller must release returned object using delete when done.
   35 */
   36 ISO9660::Stat *
   37 ISO9660::FS::find_lsn(lsn_t i_lsn)
   38 {
   39   return new Stat(iso9660_find_fs_lsn(p_cdio, i_lsn));
   40 }
   41 
   42 /*!
   43   Read the Primary Volume Descriptor for a CD.
   44   True is returned if read, and false if there was an error.
   45 */
   46 ISO9660::PVD *
   47 ISO9660::FS::read_pvd ()
   48 {
   49   iso9660_pvd_t pvd;
   50   bool b_okay = iso9660_fs_read_pvd (p_cdio, &pvd);
   51   if (b_okay) {
   52     return new PVD(&pvd);
   53   }
   54   return (PVD *) NULL;
   55 }
   56 
   57 /*!
   58   Read the Super block of an ISO 9660 image. This is the
   59   Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
   60   Descriptor if (Joliet) extensions are acceptable.
   61 */
   62 bool
   63 ISO9660::FS::read_superblock (iso_extension_mask_t iso_extension_mask)
   64 {
   65   return iso9660_fs_read_superblock (p_cdio, iso_extension_mask);
   66 }
   67 
   68 /*! Read psz_path (a directory) and return a list of iso9660_stat_t
   69   pointers for the files inside that directory. The caller must free the
   70   returned result.
   71 */
   72 bool
   73 ISO9660::FS::readdir (const char psz_path[], stat_vector_t& stat_vector)
   74 {
   75   CdioList_t * p_stat_list = iso9660_fs_readdir (p_cdio, psz_path);
   76   if (p_stat_list) {
   77     CdioListNode_t *p_entnode;
   78     _CDIO_LIST_FOREACH (p_entnode, p_stat_list) {
   79       iso9660_stat_t *p_statbuf =
   80     (iso9660_stat_t *) _cdio_list_node_data (p_entnode);
   81       stat_vector.push_back(new ISO9660::Stat(p_statbuf));
   82     }
   83     _cdio_list_free (p_stat_list, false, (CdioDataFree_t) iso9660_stat_free);
   84     return true;
   85   } else {
   86     return false;
   87   }
   88 }
   89 
   90 /*! Close previously opened ISO 9660 image and free resources
   91   associated with the image. Call this when done using using an ISO
   92   9660 image.
   93 
   94   @return true is unconditionally returned. If there was an error
   95   false would be returned.
   96 */
   97 bool
   98 ISO9660::IFS::close()
   99 {
  100   iso9660_close(p_iso9660);
  101   p_iso9660 = (iso9660_t *) NULL;
  102   return true;
  103 }
  104 
  105 /*!
  106   Given a directory pointer, find the filesystem entry that contains
  107   lsn and return information about it.
  108 
  109   Returns Stat*  of entry if we found lsn, or NULL otherwise.
  110   Caller must release returned object using delete when done.
  111 */
  112 ISO9660::Stat *
  113 ISO9660::IFS::find_lsn(lsn_t i_lsn)
  114 {
  115   return new Stat(iso9660_ifs_find_lsn(p_iso9660, i_lsn));
  116 }
  117 
  118 /*!
  119   Return the Joliet level recognized.
  120 */
  121 uint8_t
  122 ISO9660::IFS::get_joliet_level()
  123 {
  124   return iso9660_ifs_get_joliet_level(p_iso9660);
  125 }
  126 
  127 /*!
  128   Return true if ISO 9660 image has extended attrributes (XA).
  129 */
  130 bool
  131 ISO9660::IFS::is_xa ()
  132 {
  133   return iso9660_ifs_is_xa (p_iso9660);
  134 }
  135 
  136 /*! Open an ISO 9660 image for "fuzzy" reading. This means that we
  137   will try to guess various internal offset based on internal
  138   checks. This may be useful when trying to read an ISO 9660 image
  139   contained in a file format that libiso9660 doesn't know natively
  140   (or knows imperfectly.)
  141 
  142   Maybe in the future we will have a mode. NULL is returned on
  143   error.
  144 
  145   @see open
  146 */
  147 bool
  148 ISO9660::IFS::open_fuzzy (const char *psz_path,
  149               iso_extension_mask_t iso_extension_mask,
  150               uint16_t i_fuzz)
  151 {
  152   p_iso9660 = iso9660_open_fuzzy_ext(psz_path, iso_extension_mask, i_fuzz);
  153   //return p_iso9660 != (iso9660_t *) NULL;
  154   return true;
  155 }
  156 
  157 /*! Read the Primary Volume Descriptor for an ISO 9660 image.  A
  158   PVD object is returned if read, and NULL if there was an error.
  159 */
  160 ISO9660::PVD *
  161 ISO9660::IFS::read_pvd ()
  162 {
  163   iso9660_pvd_t pvd;
  164   bool b_okay = iso9660_ifs_read_pvd (p_iso9660, &pvd);
  165   if (b_okay) {
  166     return new PVD(&pvd);
  167   }
  168   return (PVD *) NULL;
  169 }
  170 
  171 /*!
  172   Read the Super block of an ISO 9660 image but determine framesize
  173   and datastart and a possible additional offset. Generally here we are
  174   not reading an ISO 9660 image but a CD-Image which contains an ISO 9660
  175   filesystem.
  176 
  177   @see read_superblock
  178 */
  179 bool
  180 ISO9660::IFS::read_superblock (iso_extension_mask_t iso_extension_mask,
  181                    uint16_t i_fuzz)
  182 {
  183   return iso9660_ifs_read_superblock (p_iso9660, iso_extension_mask);
  184 }
  185 
  186 /*!
  187   Read the Super block of an ISO 9660 image but determine framesize
  188   and datastart and a possible additional offset. Generally here we are
  189   not reading an ISO 9660 image but a CD-Image which contains an ISO 9660
  190   filesystem.
  191 
  192   @see read_superblock
  193 */
  194 bool
  195 ISO9660::IFS::read_superblock_fuzzy (iso_extension_mask_t iso_extension_mask,
  196                      uint16_t i_fuzz)
  197 {
  198   return iso9660_ifs_fuzzy_read_superblock (p_iso9660, iso_extension_mask,
  199                         i_fuzz);
  200 }
  201 
  202 char *
  203 ISO9660::PVD::get_application_id()
  204 {
  205   return iso9660_get_application_id(&pvd);
  206 }
  207 
  208 int
  209 ISO9660::PVD::get_pvd_block_size()
  210 {
  211   return iso9660_get_pvd_block_size(&pvd);
  212 }
  213 
  214 /*!
  215   Return the PVD's preparer ID.
  216   NULL is returned if there is some problem in getting this.
  217 */
  218 char *
  219 ISO9660::PVD::get_preparer_id()
  220 {
  221   return iso9660_get_preparer_id(&pvd);
  222 }
  223 
  224 /*!
  225   Return the PVD's publisher ID.
  226   NULL is returned if there is some problem in getting this.
  227 */
  228 char *
  229 ISO9660::PVD::get_publisher_id()
  230 {
  231   return iso9660_get_publisher_id(&pvd);
  232 }
  233 
  234 const char *
  235 ISO9660::PVD::get_pvd_id()
  236 {
  237   return iso9660_get_pvd_id(&pvd);
  238 }
  239 
  240 int
  241 ISO9660::PVD::get_pvd_space_size()
  242 {
  243   return iso9660_get_pvd_space_size(&pvd);
  244 }
  245 
  246 uint8_t
  247 ISO9660::PVD::get_pvd_type() {
  248   return iso9660_get_pvd_type(&pvd);
  249 }
  250 
  251 /*! Return the primary volume id version number (of pvd).
  252   If there is an error 0 is returned.
  253 */
  254 int
  255 ISO9660::PVD::get_pvd_version()
  256 {
  257   return iso9660_get_pvd_version(&pvd);
  258 }
  259 
  260 /*! Return the LSN of the root directory for pvd.
  261   If there is an error CDIO_INVALID_LSN is returned.
  262 */
  263 lsn_t
  264 ISO9660::PVD::get_root_lsn()
  265 {
  266   return iso9660_get_root_lsn(&pvd);
  267 }
  268 
  269 /*!
  270   Return the PVD's system ID.
  271   NULL is returned if there is some problem in getting this.
  272 */
  273 char *
  274 ISO9660::PVD::get_system_id()
  275 {
  276   return iso9660_get_system_id(&pvd);
  277 }
  278 
  279 /*!
  280   Return the PVD's volume ID.
  281   NULL is returned if there is some problem in getting this.
  282 */
  283 char *
  284 ISO9660::PVD::get_volume_id()
  285 {
  286   return iso9660_get_volume_id(&pvd);
  287 }
  288 
  289 /*!
  290   Return the PVD's volumeset ID.
  291   NULL is returned if there is some problem in getting this.
  292 */
  293 char *
  294 ISO9660::PVD::get_volumeset_id()
  295 {
  296   return iso9660_get_volumeset_id(&pvd);
  297 }