rbcdio 0.01
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +1 -0
- data/COPYING +340 -0
- data/ChangeLog +315 -0
- data/INSTALL +236 -0
- data/Makefile.am +163 -0
- data/Makefile.in +557 -0
- data/NEWS +5 -0
- data/README +75 -0
- data/Rakefile +234 -0
- data/THANKS +3 -0
- data/VERSION +1 -0
- data/VERSION.in +1 -0
- data/config.guess +1473 -0
- data/config.sub +1576 -0
- data/configure +4802 -0
- data/configure.ac +158 -0
- data/data/copying.iso +0 -0
- data/data/isofs-m1.bin +0 -0
- data/data/isofs-m1.cue +3 -0
- data/doc/created.rid +1 -0
- data/doc/fr_class_index.html +42 -0
- data/doc/fr_file_index.html +40 -0
- data/doc/fr_method_index.html +133 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/example/COPYING +340 -0
- data/example/README +47 -0
- data/example/audio.rb +186 -0
- data/example/cd-read.rb +167 -0
- data/example/copying +340 -0
- data/example/device.rb +91 -0
- data/example/drivers.rb +63 -0
- data/example/drives.rb +63 -0
- data/example/eject.rb +69 -0
- data/example/iso1.rb +89 -0
- data/example/iso2.rb +106 -0
- data/example/iso3.rb +111 -0
- data/example/tracks.rb +83 -0
- data/ext/cdio/Makefile +139 -0
- data/ext/cdio/extconf.rb +9 -0
- data/ext/cdio/rubycdio_wrap.c +3410 -0
- data/ext/iso9660/Makefile +139 -0
- data/ext/iso9660/extconf.rb +10 -0
- data/ext/iso9660/rubyiso9660_wrap.c +3005 -0
- data/install-sh +323 -0
- data/lib/Makefile +7 -0
- data/lib/cdio.rb +1000 -0
- data/lib/iso9660.rb +566 -0
- data/missing +360 -0
- data/rubycdio.m4 +14 -0
- data/swig/Makefile +7 -0
- data/swig/audio.swg +63 -0
- data/swig/compat.swg +104 -0
- data/swig/device.swg +513 -0
- data/swig/device_const.swg +144 -0
- data/swig/disc.swg +96 -0
- data/swig/read.swg +164 -0
- data/swig/rubycdio.swg +86 -0
- data/swig/rubyiso9660.swg +827 -0
- data/swig/track.swg +206 -0
- data/swig/types.swg +65 -0
- data/test/Makefile +7 -0
- data/test/Rakefile +8 -0
- data/test/cdda.bin +0 -0
- data/test/cdda.cue +7 -0
- data/test/cdda.toc +14 -0
- data/test/cdiotest.rb +228 -0
- data/test/isocopy.rb +394 -0
- data/test/isotest.rb +187 -0
- metadata +116 -0
data/lib/iso9660.rb
ADDED
@@ -0,0 +1,566 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# $Id: iso9660.rb,v 1.11 2006/12/16 13:24:48 rocky Exp $
|
3
|
+
#
|
4
|
+
# Copyright (C) 2006 Rocky Bernstein <rocky@gnu.org>
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19
|
+
# 02110-1301 USA.
|
20
|
+
#
|
21
|
+
# Author:: Rocky Bernstein (mailto:rocky@gnu.org)
|
22
|
+
#
|
23
|
+
# = iso9660
|
24
|
+
# Module for ISO 9660 handling
|
25
|
+
# == Version
|
26
|
+
# :include:VERSION
|
27
|
+
#
|
28
|
+
# ==SYNOPSIS
|
29
|
+
#
|
30
|
+
# This encapsulates IS9660 filesystem handling. This library however
|
31
|
+
# needs to be used in conjunction with classes Device
|
32
|
+
# ISO9660::IFS and ISO9660::FS.
|
33
|
+
#
|
34
|
+
# require "iso9660"
|
35
|
+
# name = ISO9660::name_translate('COPYING.;1')
|
36
|
+
# bool = ISO9660::is_achar('A')
|
37
|
+
#
|
38
|
+
# == DESCRIPTION
|
39
|
+
#
|
40
|
+
# This is an Ruby interface to the GNU CD Input and
|
41
|
+
# Control library's ISO 9660 library, <tt>libiso9660</tt>.
|
42
|
+
#
|
43
|
+
# Encapsulation is done in two parts. The lower-level Ruby interface is
|
44
|
+
# called Rubyiso9660 and is generated by SWIG.
|
45
|
+
#
|
46
|
+
# The more object-oriented package ISO9660 and uses
|
47
|
+
# Rubyiso9660.
|
48
|
+
#
|
49
|
+
# Although Rubyiso9660 is perfectly usable on its own, it is expected
|
50
|
+
# that these module and classes are what most people will use. As
|
51
|
+
# Rubyiso9660 more closely models the C interface, it is conceivable (if
|
52
|
+
# unlikely) that die-hard libiso9660 C users who are very familiar with
|
53
|
+
# that interface could prefer that.
|
54
|
+
|
55
|
+
|
56
|
+
require "cdio"
|
57
|
+
require "rubyiso9660"
|
58
|
+
|
59
|
+
# General device or driver exceptions
|
60
|
+
class DeviceException < Exception
|
61
|
+
end
|
62
|
+
|
63
|
+
class ISO9660
|
64
|
+
|
65
|
+
# = ISO 9660 Filesystem image reading
|
66
|
+
# == SYNOPSIS
|
67
|
+
#
|
68
|
+
# This encapsulates ISO 9660 filesystem Image handling. The class is
|
69
|
+
# often used in conjunction with ISO9660.
|
70
|
+
#
|
71
|
+
# require "cdio"
|
72
|
+
# require "iso9660"
|
73
|
+
#
|
74
|
+
# iso = ISO9660::IFS::new('copying.iso')
|
75
|
+
# id = iso.get_application_id()
|
76
|
+
# file_stats = iso.readdir($path)
|
77
|
+
# for stat in file_stats
|
78
|
+
# filename = stat["filename"]
|
79
|
+
# lsn = stat["lsn"]
|
80
|
+
# size = stat["size"]
|
81
|
+
# sec_size = stat["secsize"]
|
82
|
+
# is_dir = stat["type"] == 2 ? 'd' : '-'
|
83
|
+
# puts "%s [LSN %6d] %8d %s%s" % [is_dir, lsn, size, path,
|
84
|
+
# name_translate(filename)]
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
# == DESCRIPTION
|
88
|
+
#
|
89
|
+
# This is an Ruby interface to the GNU CD Input and Control library
|
90
|
+
# (libcdio) which is written in C. This class handles ISO 9660
|
91
|
+
# aspects of an ISO 9600 image. An ISO 9660 image is distinct from a
|
92
|
+
# CD or a CD iamge in that the latter contains other CD-like
|
93
|
+
# information (e.g. tracks, information or assocated with the
|
94
|
+
# CD). See also ISO9660::FS for working with a CD or CD image.
|
95
|
+
|
96
|
+
|
97
|
+
class IFS
|
98
|
+
|
99
|
+
# Create a new ISO 9660 object. If source is given, open()
|
100
|
+
# is called using that and the optional iso_mask parameter;
|
101
|
+
# iso_mask is used only if source is specified. If source is
|
102
|
+
# given but opening fails, nil is returned. If source is not
|
103
|
+
# given, an object is always returned.
|
104
|
+
def initialize(source=nil, iso_mask=Rubyiso9660::EXTENSION_NONE)
|
105
|
+
@iso9660 = nil
|
106
|
+
if source
|
107
|
+
open(source, iso_mask)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Returns: bool
|
112
|
+
#
|
113
|
+
# Close previously opened ISO 9660 image and free resources
|
114
|
+
# associated with ISO9660. Call this when done using using
|
115
|
+
# an ISO 9660 image.
|
116
|
+
def close()
|
117
|
+
if @iso9660
|
118
|
+
Rubyiso9660::close(@iso9660)
|
119
|
+
else
|
120
|
+
puts "***No object to close"
|
121
|
+
end
|
122
|
+
@iso9660 = nil
|
123
|
+
end
|
124
|
+
|
125
|
+
# Returns: [stat_href]
|
126
|
+
#
|
127
|
+
# Find the filesystem entry that contains LSN and return
|
128
|
+
# file stat information about it. nil is returned on
|
129
|
+
# error.
|
130
|
+
def find_lsn(lsn)
|
131
|
+
|
132
|
+
if Rubycdio::VERSION_NUM <= 76
|
133
|
+
puts "*** Routine available only in libcdio versions >= 0.76"
|
134
|
+
return nil
|
135
|
+
end
|
136
|
+
|
137
|
+
return Rubyiso9660::ifs_find_lsn(@iso9660, lsn)
|
138
|
+
end
|
139
|
+
|
140
|
+
# Returns: String (id)
|
141
|
+
#
|
142
|
+
# Get the application ID stored in the Primary Volume Descriptor.
|
143
|
+
# nil is returned if there is some problem.
|
144
|
+
def application_id()
|
145
|
+
return Rubyiso9660::ifs_get_application_id(@iso9660)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Returns: String (id)
|
149
|
+
#
|
150
|
+
# Get the preparer ID stored in the Primary Volume Descriptor.
|
151
|
+
# nil is returned if there is some problem.
|
152
|
+
def preparer_id()
|
153
|
+
return Rubyiso9660::ifs_get_preparer_id(@iso9660)
|
154
|
+
end
|
155
|
+
|
156
|
+
# Returns: String (id)
|
157
|
+
#
|
158
|
+
# Get the publisher ID stored in the Primary Volume Descriptor.
|
159
|
+
# nil is returned if there is some problem.
|
160
|
+
def publisher_id()
|
161
|
+
return Rubyiso9660::ifs_get_publisher_id(@iso9660)
|
162
|
+
end
|
163
|
+
|
164
|
+
# Returns: Fixnum (lsn)
|
165
|
+
#
|
166
|
+
# Get the Root LSN stored in the Primary Volume Descriptor.
|
167
|
+
# nil is returned if there is some problem.
|
168
|
+
def root_lsn()
|
169
|
+
return Rubyiso9660::ifs_get_root_lsn(@iso9660)
|
170
|
+
end
|
171
|
+
|
172
|
+
# Returns: String (id)
|
173
|
+
#
|
174
|
+
# Get the Volume ID stored in the Primary Volume Descriptor.
|
175
|
+
# nil is returned if there is some problem.
|
176
|
+
#
|
177
|
+
def system_id()
|
178
|
+
return Rubyiso9660::ifs_get_system_id(@iso9660)
|
179
|
+
end
|
180
|
+
|
181
|
+
# Returns; String (id)
|
182
|
+
#
|
183
|
+
# Get the Volume ID stored in the Primary Volume Descriptor.
|
184
|
+
# nil is returned if there is some problem.
|
185
|
+
def volume_id()
|
186
|
+
return Rubyiso9660::ifs_get_volume_id(@iso9660)
|
187
|
+
end
|
188
|
+
|
189
|
+
# Returns: String (id)
|
190
|
+
#
|
191
|
+
# Get the Volume ID stored in the Primary Volume Descriptor.
|
192
|
+
# nil is returned if there is some problem.
|
193
|
+
def volumeset_id()
|
194
|
+
return Rubyiso9660::ifs_get_volumeset_id(@iso9660)
|
195
|
+
end
|
196
|
+
|
197
|
+
# Returns: bool
|
198
|
+
#
|
199
|
+
# Return true if we have an ISO9660 image open.
|
200
|
+
#
|
201
|
+
def open?()
|
202
|
+
return @iso9660 != nil
|
203
|
+
end
|
204
|
+
|
205
|
+
# Open an ISO 9660 image for reading. Subsequent operations
|
206
|
+
# will read from this ISO 9660 image.
|
207
|
+
#
|
208
|
+
# This should be called before using any other routine
|
209
|
+
# except possibly new. It is implicitly called when a new is
|
210
|
+
# done specifying a source.
|
211
|
+
#
|
212
|
+
# If device object was previously opened it is closed first.
|
213
|
+
#
|
214
|
+
# See also open_fuzzy.
|
215
|
+
def open(source, iso_mask=Rubyiso9660::EXTENSION_NONE)
|
216
|
+
if @iso9660 != nil then close() end
|
217
|
+
|
218
|
+
@iso9660 = Rubyiso9660::open_ext(source, iso_mask)
|
219
|
+
return @iso9660 != nil
|
220
|
+
end
|
221
|
+
|
222
|
+
# Open an ISO 9660 image for reading. Subsequent operations
|
223
|
+
# will read from this ISO 9660 image. Some tolerence allowed
|
224
|
+
# for positioning the ISO9660 image. We scan for
|
225
|
+
# Rubyiso9660::STANDARD_ID and use that to set the eventual
|
226
|
+
# offset to adjust by (as long as that is <= fuzz).
|
227
|
+
#
|
228
|
+
# This should be called before using any other routine
|
229
|
+
# except possibly new (which must be called first. It is
|
230
|
+
# implicitly called when a new is done specifying a source.
|
231
|
+
#
|
232
|
+
# See also open.
|
233
|
+
|
234
|
+
def open_fuzzy(source, iso_mask=Rubyiso9660::EXTENSION_NONE,
|
235
|
+
fuzz=20)
|
236
|
+
if @iso9660 != nil then close() end
|
237
|
+
|
238
|
+
if fuzz.class != Fixnum
|
239
|
+
puts "*** Expecting fuzz to be an integer; got 'fuzz'"
|
240
|
+
return false
|
241
|
+
end
|
242
|
+
|
243
|
+
@iso9660 = Rubyiso9660::open_fuzzy_ext(source, iso_mask, fuzz)
|
244
|
+
return @iso9660
|
245
|
+
end
|
246
|
+
|
247
|
+
# Read the Super block of an ISO 9660 image but determine
|
248
|
+
# framesize and datastart and a possible additional
|
249
|
+
# offset. Generally here we are not reading an ISO 9660 image
|
250
|
+
# but a CD-Image which contains an ISO 9660 filesystem.
|
251
|
+
def read_fuzzy_superblock(iso_mask=Rubyiso9660::EXTENSION_NONE,
|
252
|
+
fuzz=20)
|
253
|
+
if fuzz.class != Fixnum
|
254
|
+
puts "*** Expecting fuzz to be an integer; got 'fuzz'"
|
255
|
+
return false
|
256
|
+
end
|
257
|
+
|
258
|
+
return Rubyiso9660::ifs_fuzzy_read_superblock(@iso9660,
|
259
|
+
iso_mask,
|
260
|
+
fuzz)
|
261
|
+
end
|
262
|
+
|
263
|
+
# Read path (a directory) and return a list of iso9660 stat
|
264
|
+
# references
|
265
|
+
#
|
266
|
+
# Each item of @iso_stat is a hash which contains
|
267
|
+
#
|
268
|
+
# * lsn - the Logical sector number (an integer)
|
269
|
+
# * size - the total size of the file in bytes
|
270
|
+
# * secsize - the number of sectors allocated
|
271
|
+
# * filename - the file name of the statbuf entry
|
272
|
+
def readdir(dirname)
|
273
|
+
#---
|
274
|
+
# FIXME: If you look at iso9660.h you'll see more fields,
|
275
|
+
# such as for Rock-Ridge specific fields or XA specific
|
276
|
+
# fields. Eventually these will be added. Volunteers?
|
277
|
+
#+++
|
278
|
+
return Rubyiso9660::ifs_readdir(@iso9660, dirname)
|
279
|
+
end
|
280
|
+
|
281
|
+
|
282
|
+
# Returns: pvd
|
283
|
+
#
|
284
|
+
# Read the Super block of an ISO 9660 image. This is the
|
285
|
+
# Primary Volume Descriptor (PVD) and perhaps a Supplemental
|
286
|
+
# Volume Descriptor if (Joliet) extensions are
|
287
|
+
# acceptable.
|
288
|
+
def read_pvd()
|
289
|
+
return Rubyiso9660::ifs_read_pvd(@iso9660)
|
290
|
+
end
|
291
|
+
|
292
|
+
# Returns: bool
|
293
|
+
#
|
294
|
+
# Read the Super block of an ISO 9660 image. This is the
|
295
|
+
# Primary Volume Descriptor (PVD) and perhaps a Supplemental
|
296
|
+
# Volume Descriptor if (Joliet) extensions are
|
297
|
+
# acceptable.
|
298
|
+
def read_superblock(iso_mask=Rubyiso9660::EXTENSION_NONE)
|
299
|
+
|
300
|
+
return Rubyiso9660::ifs_read_superblock(@iso9660, iso_mask)
|
301
|
+
end
|
302
|
+
|
303
|
+
# Returns; [size, str]
|
304
|
+
#
|
305
|
+
# Seek to a position and then read n blocks. A block is
|
306
|
+
# Rubycdio::ISO_BLOCKSIZE (2048) bytes. The Size in BYTES (not blocks)
|
307
|
+
# is returned.
|
308
|
+
def seek_read(start, size=1)
|
309
|
+
size *= Rubyiso9660::ISO_BLOCKSIZE
|
310
|
+
return Rubyiso9660::seek_read(@iso9660, start, size)
|
311
|
+
end
|
312
|
+
|
313
|
+
# Returns: {stat}
|
314
|
+
#
|
315
|
+
# Return file status for path name psz_path. nil is returned on
|
316
|
+
# error. If translate is true, version numbers in the ISO 9660
|
317
|
+
# name are dropped, i.e. ;1 is removed and if level 1 ISO-9660
|
318
|
+
# names are lowercased.
|
319
|
+
#
|
320
|
+
# Each item of the return is a hash reference which contains:
|
321
|
+
#
|
322
|
+
# * lsn - the Logical sector number (an integer)
|
323
|
+
# * size - the total size of the file in bytes
|
324
|
+
# * sec_size - the number of sectors allocated
|
325
|
+
# * filename - the file name of the statbuf entry
|
326
|
+
def stat(path, translate=false)
|
327
|
+
|
328
|
+
if translate
|
329
|
+
values = Rubyiso9660::ifs_stat_translate(@iso9660, path)
|
330
|
+
else
|
331
|
+
values = Rubyiso9660::ifs_stat(@iso9660, path)
|
332
|
+
end
|
333
|
+
return values
|
334
|
+
end
|
335
|
+
end # IFS
|
336
|
+
|
337
|
+
# = ISO 9660 Filesystem reading
|
338
|
+
# == SYNOPSIS
|
339
|
+
#
|
340
|
+
# This encapsulates ISO-9660 Filesystem aspects of CD Tracks.
|
341
|
+
# As such this is a This library
|
342
|
+
# however needs to be used in conjunction with ISO9660.
|
343
|
+
#
|
344
|
+
# require "iso9660"
|
345
|
+
# cd = ISO9660::FS::new('/dev/cdrom')
|
346
|
+
# statbuf = cd.stat("filename")
|
347
|
+
#
|
348
|
+
# blocks = (statbuf['size'].to_f / Rubycdio::ISO_BLOCKSIZE).ceil()
|
349
|
+
# for i in 0.. block - 1
|
350
|
+
# lsn = statbuf['lsn'] + i
|
351
|
+
# size, buf = cd.read_data_blocks(lsn)
|
352
|
+
# puts buf
|
353
|
+
# end
|
354
|
+
#
|
355
|
+
# == DESCRIPTION
|
356
|
+
#
|
357
|
+
# This is an Object-Oriented interface to the GNU CD Input and Control
|
358
|
+
# library (libcdio) which is written in C. This class handles ISO
|
359
|
+
# 9660 aspects of a tracks from a CD in a CD-ROM or as a track of a CD
|
360
|
+
# image. A CD image is distinct from an ISO 9660 image in that a CD
|
361
|
+
# image contains other CD-line information (e.g. tracks, information or
|
362
|
+
# assocated with the CD). See also ISO9660::IFS for working with an
|
363
|
+
# ISO 9660 image.
|
364
|
+
|
365
|
+
class FS < Device
|
366
|
+
|
367
|
+
# find_lsn(lsn)->[stat_href]
|
368
|
+
#
|
369
|
+
# Find the filesystem entry that contains LSN and return
|
370
|
+
# file stat information about it. nil is returned on
|
371
|
+
# error.
|
372
|
+
def find_lsn(lsn)
|
373
|
+
return Rubyiso9660::fs_find_lsn(@cd, lsn)
|
374
|
+
end
|
375
|
+
|
376
|
+
|
377
|
+
# Read path (a directory) and return a list of iso9660 stat
|
378
|
+
# references
|
379
|
+
#
|
380
|
+
# Each item of a hash which contains
|
381
|
+
#
|
382
|
+
# * lsn - the Logical sector number (an integer)
|
383
|
+
# * size - the total size of the file in bytes
|
384
|
+
# * sec_size - the number of sectors allocated
|
385
|
+
# * filename - the file name of the statbuf entry
|
386
|
+
# * is_dir - 2 if a directory; 0 if a not;
|
387
|
+
#
|
388
|
+
# FIXME: If you look at iso9660.h you'll see more fields, such as for
|
389
|
+
# Rock-Ridge specific fields or XA specific fields. Eventually these
|
390
|
+
# will be added. Volunteers?
|
391
|
+
|
392
|
+
def readdir(dirname)
|
393
|
+
return Rubyiso9660::fs_readdir(@cd, dirname)
|
394
|
+
end
|
395
|
+
|
396
|
+
# Returns: pvd
|
397
|
+
#
|
398
|
+
# Read the Super block of an ISO 9660 image. This is the
|
399
|
+
# Primary Volume Descriptor (PVD) and perhaps a Supplemental
|
400
|
+
# Volume Descriptor if (Joliet) extensions are
|
401
|
+
# acceptable.
|
402
|
+
def read_pvd()
|
403
|
+
return Rubyiso9660::fs_read_pvd(@cd)
|
404
|
+
end # read_pvd
|
405
|
+
|
406
|
+
# read_superblock(iso_mask=Rubyiso9660::EXTENSION_NONE)->bool
|
407
|
+
#
|
408
|
+
# Read the Super block of an ISO 9660 image. This is the
|
409
|
+
# Primary Volume Descriptor (PVD) and perhaps a Supplemental
|
410
|
+
# Volume Descriptor if (Joliet) extensions are
|
411
|
+
# acceptable.
|
412
|
+
def read_superblock(iso_mask=Rubyiso9660::EXTENSION_NONE)
|
413
|
+
return Rubyiso9660::fs_read_superblock(@cd, iso_mask)
|
414
|
+
end # read_superblock
|
415
|
+
|
416
|
+
# Returns: {stat}
|
417
|
+
#
|
418
|
+
# Return file status for path name psz_path. nil is returned on
|
419
|
+
# error. If translate is true, version numbers in the ISO 9660
|
420
|
+
# name are dropped, i.e. ;1 is removed and if level 1 ISO-9660
|
421
|
+
# names are lowercased.
|
422
|
+
#
|
423
|
+
# Each item of the return is a hash reference which contains:
|
424
|
+
#
|
425
|
+
# * lsn - the Logical sector number (an integer)
|
426
|
+
# * size - the total size of the file in bytes
|
427
|
+
# * secsize - the number of sectors allocated
|
428
|
+
# * filename - the file name of the statbuf entry
|
429
|
+
# * is_dir - true if a directory; false if a not.
|
430
|
+
def stat(path, translate=false)
|
431
|
+
if translate
|
432
|
+
value = Rubyiso9660::fs_stat_translate(@cd, path)
|
433
|
+
else
|
434
|
+
value = Rubyiso9660::fs_stat(@cd, path)
|
435
|
+
end
|
436
|
+
return value
|
437
|
+
end # stat
|
438
|
+
end # class FS
|
439
|
+
end # class ISO9660
|
440
|
+
|
441
|
+
def ISO9660.check_types()
|
442
|
+
return {
|
443
|
+
:"nocheck" => Rubyiso9660::NOCHECK,
|
444
|
+
:"7bit" => Rubyiso9660::SEVEN_BIT,
|
445
|
+
:"achars" => Rubyiso9660::ACHARS,
|
446
|
+
:"dchars" => Rubyiso9660::DCHARS
|
447
|
+
}
|
448
|
+
end
|
449
|
+
|
450
|
+
# Returns: bool
|
451
|
+
#
|
452
|
+
# Check that path is a valid ISO-9660 directory name.
|
453
|
+
#
|
454
|
+
# A valid directory name should not start out with a slash (/),
|
455
|
+
# dot (.) or null byte, should be less than 37 characters long,
|
456
|
+
# have no more than 8 characters in a directory component
|
457
|
+
# which is separated by a /, and consist of only DCHARs.
|
458
|
+
#
|
459
|
+
# true is returned if path is valid.
|
460
|
+
def ISO9660.dirname_valid?(path)
|
461
|
+
return Rubyiso9660::dirname_valid?(path)
|
462
|
+
end
|
463
|
+
|
464
|
+
# Returns: bool
|
465
|
+
#
|
466
|
+
# Return 1 if achar is an ISO-9660 ACHAR. achar should either be a string of
|
467
|
+
# length one or the ord() of a string of length 1.
|
468
|
+
#
|
469
|
+
# These are the DCHAR's plus some ASCII symbols including the space
|
470
|
+
# symbol.
|
471
|
+
def ISO9660.achar?(achar)
|
472
|
+
if achar.class == Fixnum
|
473
|
+
# Is an integer. Is it too large?
|
474
|
+
if achar > 255 then return false end
|
475
|
+
elsif achar.class == String and achar.length() == 1
|
476
|
+
achar = achar[0]
|
477
|
+
else
|
478
|
+
return false
|
479
|
+
end
|
480
|
+
return Rubyiso9660::achar?(achar)
|
481
|
+
end
|
482
|
+
|
483
|
+
# Returns: bool
|
484
|
+
#
|
485
|
+
# Return 1 if dchar is a ISO-9660 DCHAR - a character that can appear in an an
|
486
|
+
# ISO-9600 level 1 directory name. These are the ASCII capital
|
487
|
+
# letters A-Z, the digits 0-9 and an underscore.
|
488
|
+
#
|
489
|
+
# dchar should either be a string of length one or the ord() of a string
|
490
|
+
# of length 1.
|
491
|
+
def ISO9660.dchar?(dchar)
|
492
|
+
if dchar.class == Fixnum
|
493
|
+
# Is an integer. Is it too large?
|
494
|
+
if dchar > 255 then return false end
|
495
|
+
# Not integer. Should be a string of length one then.
|
496
|
+
# We'll turn it into an integer.
|
497
|
+
elsif
|
498
|
+
dchar = dchar[0]
|
499
|
+
else
|
500
|
+
return false
|
501
|
+
end
|
502
|
+
return Rubyiso9660::dchar?(dchar)
|
503
|
+
end
|
504
|
+
|
505
|
+
# Returns: bool
|
506
|
+
#
|
507
|
+
# Check that path is a valid ISO-9660 pathname.
|
508
|
+
#
|
509
|
+
# A valid pathname contains a valid directory name, if one appears and
|
510
|
+
# the filename portion should be no more than 8 characters for the
|
511
|
+
# file prefix and 3 characters in the extension (or portion after a
|
512
|
+
# dot). There should be exactly one dot somewhere in the filename
|
513
|
+
# portion and the filename should be composed of only DCHARs.
|
514
|
+
#
|
515
|
+
# true is returned if path is valid.
|
516
|
+
def ISO9660.pathname_valid?(path)
|
517
|
+
return Rubyiso9660::pathname_valid?(path)
|
518
|
+
end
|
519
|
+
|
520
|
+
# Take path and a version number and turn that into a ISO-9660
|
521
|
+
# pathname. (That's just the pathname followed by ';' and the version
|
522
|
+
# number. For example, mydir/file.ext -> MYDIR/FILE.EXT;1 for version 1.
|
523
|
+
# The resulting ISO-9660 pathname is returned.
|
524
|
+
def ISO9660.pathname_isofy(path, version=1)
|
525
|
+
return Rubyiso9660::pathname_isofy(path, version)
|
526
|
+
end
|
527
|
+
|
528
|
+
# Returns: String
|
529
|
+
#
|
530
|
+
# Convert an ISO-9660 file name of the kind that is that stored in a ISO
|
531
|
+
# 9660 directory entry into what's usually listed as the file name in a
|
532
|
+
# listing. Lowercase name if no Joliet Extension interpretation. Remove
|
533
|
+
# trailing ;1's or .;1's and turn the other ;'s into version numbers.
|
534
|
+
#
|
535
|
+
# If joliet_level is not given it is 0 which means use no Joliet
|
536
|
+
# Extensions. Otherwise use the specified the Joliet level.
|
537
|
+
#
|
538
|
+
# The translated string is returned and it will be larger than the input
|
539
|
+
# filename.
|
540
|
+
def ISO9660.name_translate(filename, joliet_level=0)
|
541
|
+
return Rubyiso9660::name_translate_ext(filename, joliet_level)
|
542
|
+
end
|
543
|
+
|
544
|
+
#---
|
545
|
+
# FIXME: should be
|
546
|
+
# def stat_array_to_dict(*args):
|
547
|
+
# Probably have a SWIG error.
|
548
|
+
#+++
|
549
|
+
|
550
|
+
# Returns: String
|
551
|
+
#
|
552
|
+
# Pad string 'name' with spaces to size len and return this. If 'len' is
|
553
|
+
# less than the length of 'src', the return value will be truncated to
|
554
|
+
# the first len characters of 'name'.
|
555
|
+
#
|
556
|
+
# 'name' can also be scanned to see if it contains only ACHARs, DCHARs,
|
557
|
+
# or 7-bit ASCII chars, and this is specified via the 'check' parameter.
|
558
|
+
# If the I<check> parameter is given it must be one of the 'nocheck',
|
559
|
+
# '7bit', 'achars' or 'dchars'. Case is not significant.
|
560
|
+
def ISO9660.strncpy_pad(name, len, check)
|
561
|
+
if not ISO9660.check_types().member?(check)
|
562
|
+
puts "*** A CHECK parameter must be one of %s\n" % ISO9660.check_types.keys().join(',')
|
563
|
+
return nil
|
564
|
+
end
|
565
|
+
return Rubyiso9660::strncpy_pad(name, len, ISO9660.check_types()[check])
|
566
|
+
end
|