Class: ISO9660::FS

Inherits:
Device
  • Object
show all
Defined in:
lib/iso9660.rb

Overview

ISO 9660 Filesystem reading

SYNOPSIS

This encapsulates ISO-9660 Filesystem aspects of CD Tracks. As such this is a This library however needs to be used in conjunction with ISO9660.

require "iso9660"
cd = ISO9660::FS::new('/dev/cdrom')
statbuf = cd.stat("filename")

blocks = (statbuf['size'].to_f / Rubycdio::ISO_BLOCKSIZE).ceil()
for i in 0.. block - 1
    lsn = statbuf['lsn'] + i
    size, buf = cd.read_data_blocks(lsn)
    puts buf  
end

DESCRIPTION

This is an Object-Oriented interface to the GNU CD Input and Control library (libcdio) which is written in C. This class handles ISO 9660 aspects of a tracks from a CD in a CD-ROM or as a track of a CD image. A CD image is distinct from an ISO 9660 image in that a CD image contains other CD-line information (e.g. tracks, information or assocated with the CD). See also ISO9660::IFS for working with an ISO 9660 image.

Instance Method Summary collapse

Instance Method Details

#find_lsn(lsn) ⇒ Object

find_lsn(lsn)->

Find the filesystem entry that contains LSN and return file stat information about it. nil is returned on error.



370
371
372
# File 'lib/iso9660.rb', line 370

def find_lsn(lsn)
  return Rubyiso9660::fs_find_lsn(@cd, lsn)
end

#read_pvdObject

Returns: 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.



400
401
402
# File 'lib/iso9660.rb', line 400

def read_pvd()
  return Rubyiso9660::fs_read_pvd(@cd)
end

#read_superblock(iso_mask = Rubyiso9660::EXTENSION_NONE) ⇒ Object

read_superblock(iso_mask=Rubyiso9660::EXTENSION_NONE)->bool

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.



410
411
412
# File 'lib/iso9660.rb', line 410

def read_superblock(iso_mask=Rubyiso9660::EXTENSION_NONE)
  return Rubyiso9660::fs_read_superblock(@cd, iso_mask)
end

#readdir(dirname) ⇒ Object

Read path (a directory) and return a list of iso9660 stat references

Each item of a hash which contains

* lsn       - the Logical sector number (an integer)
* size      - the total size of the file in bytes
* sec_size  - the number of sectors allocated
* filename  - the file name of the statbuf entry
* is_dir    - 2 if a directory; 0 if a not;

FIXME: If you look at iso9660.h you'll see more fields, such as for
Rock-Ridge specific fields or XA specific fields. Eventually these
will be added. Volunteers?


390
391
392
# File 'lib/iso9660.rb', line 390

def readdir(dirname)
  return Rubyiso9660::fs_readdir(@cd, dirname)
end

#stat(path, translate = false) ⇒ Object

Returns: #stat

Return file status for path name psz_path. nil 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.

Each item of the return is a hash reference which contains:

* lsn      - the Logical sector number (an integer)
* size     - the total size of the file in bytes
* secsize  - the number of sectors allocated
* filename - the file name of the statbuf entry
* is_dir   - true if a directory; false if a not.


428
429
430
431
432
433
434
435
# File 'lib/iso9660.rb', line 428

def stat(path, translate=false)
  if translate
    value = Rubyiso9660::fs_stat_translate(@cd, path)
  else
    value = Rubyiso9660::fs_stat(@cd, path)
  end
  return value
end