Class: ISO9660::IFS

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

Instance Method Summary collapse

Constructor Details

#initialize(source = nil, iso_mask = Rubyiso9660::EXTENSION_NONE) ⇒ IFS

Create a new ISO 9660 object. If source is given, open() is called using that and the optional iso_mask parameter; iso_mask is used only if source is specified. If source is given but opening fails, nil is returned. If source is not given, an object is always returned.



102
103
104
105
106
107
# File 'lib/iso9660.rb', line 102

def initialize(source=nil, iso_mask=Rubyiso9660::EXTENSION_NONE)
  @iso9660 = nil
  if source
    open(source, iso_mask)
  end
end

Instance Method Details

#application_idObject

Returns: String (id)

Get the application ID stored in the Primary Volume Descriptor. nil is returned if there is some problem.



142
143
144
# File 'lib/iso9660.rb', line 142

def application_id()
  return Rubyiso9660::ifs_get_application_id(@iso9660)
end

#closeObject

Returns: bool

Close previously opened ISO 9660 image and free resources associated with ISO9660. Call this when done using using an ISO 9660 image.



114
115
116
117
118
119
120
121
# File 'lib/iso9660.rb', line 114

def close()
  if @iso9660
    Rubyiso9660::close(@iso9660)
  else
    puts "***No object to close"
  end
  @iso9660 = nil
end

#find_lsn(lsn) ⇒ Object

Returns: [stat_href]

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



128
129
130
131
132
133
134
135
136
# File 'lib/iso9660.rb', line 128

def find_lsn(lsn)

  if Rubycdio::VERSION_NUM <= 76
    puts "*** Routine available only in libcdio versions >= 0.76"
    return nil
  end
  
  return Rubyiso9660::ifs_find_lsn(@iso9660, lsn)
end

#open(source, iso_mask = Rubyiso9660::EXTENSION_NONE) ⇒ Object

Open an ISO 9660 image for reading. Subsequent operations will read from this ISO 9660 image.

This should be called before using any other routine except possibly new. It is implicitly called when a new is done specifying a source.

If device object was previously opened it is closed first.

See also open_fuzzy.



213
214
215
216
217
218
# File 'lib/iso9660.rb', line 213

def open(source, iso_mask=Rubyiso9660::EXTENSION_NONE)
  if @iso9660 != nil then close() end

  @iso9660 = Rubyiso9660::open_ext(source, iso_mask)
  return @iso9660 !=  nil
end

#open?Boolean

Returns: bool

Return true if we have an ISO9660 image open.

Returns:

  • (Boolean)


199
200
201
# File 'lib/iso9660.rb', line 199

def open?()
  return @iso9660 != nil
end

#open_fuzzy(source, iso_mask = Rubyiso9660::EXTENSION_NONE, fuzz = 20) ⇒ Object

Open an ISO 9660 image for reading. Subsequent operations will read from this ISO 9660 image. Some tolerence allowed for positioning the ISO9660 image. We scan for Rubyiso9660::STANDARD_ID and use that to set the eventual offset to adjust by (as long as that is <= fuzz).

This should be called before using any other routine except possibly new (which must be called first. It is implicitly called when a new is done specifying a source.

See also open.



232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/iso9660.rb', line 232

def open_fuzzy(source, iso_mask=Rubyiso9660::EXTENSION_NONE,
               fuzz=20)
  if @iso9660 != nil then close()  end
  
  if fuzz.class  != Fixnum
    puts "*** Expecting fuzz to be an integer; got 'fuzz'"
    return false
  end
  
  @iso9660 = Rubyiso9660::open_fuzzy_ext(source, iso_mask, fuzz)
  return @iso9660
end

#preparer_idObject

Returns: String (id)

Get the preparer ID stored in the Primary Volume Descriptor. nil is returned if there is some problem.



150
151
152
# File 'lib/iso9660.rb', line 150

def preparer_id()
  return Rubyiso9660::ifs_get_preparer_id(@iso9660)
end

#publisher_idObject

Returns: String (id)

Get the publisher ID stored in the Primary Volume Descriptor. nil is returned if there is some problem.



158
159
160
# File 'lib/iso9660.rb', line 158

def publisher_id()
  return Rubyiso9660::ifs_get_publisher_id(@iso9660)
end

#read_fuzzy_superblock(iso_mask = Rubyiso9660::EXTENSION_NONE, fuzz = 20) ⇒ Object

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.



249
250
251
252
253
254
255
256
257
258
259
# File 'lib/iso9660.rb', line 249

def read_fuzzy_superblock(iso_mask=Rubyiso9660::EXTENSION_NONE,
                          fuzz=20)
  if fuzz.class != Fixnum
    puts "*** Expecting fuzz to be an integer; got 'fuzz'"
    return false
  end
  
  return Rubyiso9660::ifs_fuzzy_read_superblock(@iso9660, 
                                                iso_mask,
                                                fuzz)
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.



286
287
288
# File 'lib/iso9660.rb', line 286

def read_pvd()
  return Rubyiso9660::ifs_read_pvd(@iso9660)
end

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

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



296
297
298
299
# File 'lib/iso9660.rb', line 296

def read_superblock(iso_mask=Rubyiso9660::EXTENSION_NONE)
  
  return Rubyiso9660::ifs_read_superblock(@iso9660, iso_mask)
end

#readdir(dirname) ⇒ Object

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

Each item of @iso_stat is a hash 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


270
271
272
273
274
275
276
277
# File 'lib/iso9660.rb', line 270

def readdir(dirname)
  #---
  #  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?
  #+++
  return Rubyiso9660::ifs_readdir(@iso9660, dirname)
end

#root_lsnObject

Returns: Fixnum (lsn)

Get the Root LSN stored in the Primary Volume Descriptor.
nil is returned if there is some problem.


166
167
168
# File 'lib/iso9660.rb', line 166

def root_lsn()
  return Rubyiso9660::ifs_get_root_lsn(@iso9660)
end

#seek_read(start, size = 1) ⇒ Object

Returns; [size, str]

Seek to a position and then read n blocks. A block is Rubycdio::ISO_BLOCKSIZE (2048) bytes. The Size in BYTES (not blocks) is returned.



306
307
308
309
# File 'lib/iso9660.rb', line 306

def seek_read(start, size=1)
  size *= Rubyiso9660::ISO_BLOCKSIZE
  return Rubyiso9660::seek_read(@iso9660, start, size)
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

  • sec_size - the number of sectors allocated

  • filename - the file name of the statbuf entry



324
325
326
327
328
329
330
331
332
# File 'lib/iso9660.rb', line 324

def stat(path, translate=false)
  
  if translate
    values = Rubyiso9660::ifs_stat_translate(@iso9660, path)
  else
    values = Rubyiso9660::ifs_stat(@iso9660, path)
  end
  return values
end

#system_idObject

Returns: String (id)

Get the Volume ID stored in the Primary Volume Descriptor. nil is returned if there is some problem.



175
176
177
# File 'lib/iso9660.rb', line 175

def system_id()
  return Rubyiso9660::ifs_get_system_id(@iso9660)
end

#volume_idObject

Returns; String (id)

Get the Volume ID stored in the Primary Volume Descriptor. nil is returned if there is some problem.



183
184
185
# File 'lib/iso9660.rb', line 183

def volume_id()
  return Rubyiso9660::ifs_get_volume_id(@iso9660)
end

#volumeset_idObject

Returns: String (id)

Get the Volume ID stored in the Primary Volume Descriptor. nil is returned if there is some problem.



191
192
193
# File 'lib/iso9660.rb', line 191

def volumeset_id()
  return Rubyiso9660::ifs_get_volumeset_id(@iso9660)
end