rbcdio 0.01

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/AUTHORS +1 -0
  2. data/COPYING +340 -0
  3. data/ChangeLog +315 -0
  4. data/INSTALL +236 -0
  5. data/Makefile.am +163 -0
  6. data/Makefile.in +557 -0
  7. data/NEWS +5 -0
  8. data/README +75 -0
  9. data/Rakefile +234 -0
  10. data/THANKS +3 -0
  11. data/VERSION +1 -0
  12. data/VERSION.in +1 -0
  13. data/config.guess +1473 -0
  14. data/config.sub +1576 -0
  15. data/configure +4802 -0
  16. data/configure.ac +158 -0
  17. data/data/copying.iso +0 -0
  18. data/data/isofs-m1.bin +0 -0
  19. data/data/isofs-m1.cue +3 -0
  20. data/doc/created.rid +1 -0
  21. data/doc/fr_class_index.html +42 -0
  22. data/doc/fr_file_index.html +40 -0
  23. data/doc/fr_method_index.html +133 -0
  24. data/doc/index.html +24 -0
  25. data/doc/rdoc-style.css +208 -0
  26. data/example/COPYING +340 -0
  27. data/example/README +47 -0
  28. data/example/audio.rb +186 -0
  29. data/example/cd-read.rb +167 -0
  30. data/example/copying +340 -0
  31. data/example/device.rb +91 -0
  32. data/example/drivers.rb +63 -0
  33. data/example/drives.rb +63 -0
  34. data/example/eject.rb +69 -0
  35. data/example/iso1.rb +89 -0
  36. data/example/iso2.rb +106 -0
  37. data/example/iso3.rb +111 -0
  38. data/example/tracks.rb +83 -0
  39. data/ext/cdio/Makefile +139 -0
  40. data/ext/cdio/extconf.rb +9 -0
  41. data/ext/cdio/rubycdio_wrap.c +3410 -0
  42. data/ext/iso9660/Makefile +139 -0
  43. data/ext/iso9660/extconf.rb +10 -0
  44. data/ext/iso9660/rubyiso9660_wrap.c +3005 -0
  45. data/install-sh +323 -0
  46. data/lib/Makefile +7 -0
  47. data/lib/cdio.rb +1000 -0
  48. data/lib/iso9660.rb +566 -0
  49. data/missing +360 -0
  50. data/rubycdio.m4 +14 -0
  51. data/swig/Makefile +7 -0
  52. data/swig/audio.swg +63 -0
  53. data/swig/compat.swg +104 -0
  54. data/swig/device.swg +513 -0
  55. data/swig/device_const.swg +144 -0
  56. data/swig/disc.swg +96 -0
  57. data/swig/read.swg +164 -0
  58. data/swig/rubycdio.swg +86 -0
  59. data/swig/rubyiso9660.swg +827 -0
  60. data/swig/track.swg +206 -0
  61. data/swig/types.swg +65 -0
  62. data/test/Makefile +7 -0
  63. data/test/Rakefile +8 -0
  64. data/test/cdda.bin +0 -0
  65. data/test/cdda.cue +7 -0
  66. data/test/cdda.toc +14 -0
  67. data/test/cdiotest.rb +228 -0
  68. data/test/isocopy.rb +394 -0
  69. data/test/isotest.rb +187 -0
  70. metadata +116 -0
data/swig/track.swg ADDED
@@ -0,0 +1,206 @@
1
+ /* -*- c -*-
2
+ $Id: track.swg,v 1.4 2006/12/03 00:20:03 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., 59 Temple Place, Suite 330, Boston=, MA 02111-1307 USA
19
+ */
20
+
21
+ /* See <cdio/track.h> For more extensive documentation */
22
+ %constant long int TRACK_FORMAT_AUDIO = TRACK_FORMAT_AUDIO;
23
+ %constant long int TRACK_FORMAT_CDI = TRACK_FORMAT_CDI;
24
+ %constant long int TRACK_FORMAT_XA = TRACK_FORMAT_XA;
25
+ %constant long int TRACK_FORMAT_DATA = TRACK_FORMAT_DATA;
26
+ %constant long int TRACK_FORMAT_PSX = TRACK_FORMAT_PSX;
27
+
28
+ %constant long int CDIO_TRACK_FLAG_FALSE = CDIO_TRACK_FLAG_FALSE;
29
+ %constant long int CDIO_TRACK_FLAG_TRUE = CDIO_TRACK_FLAG_TRUE;
30
+ %constant long int CDIO_TRACK_FLAG_ERROR = CDIO_TRACK_FLAG_ERROR;
31
+ %constant long int CDIO_TRACK_FLAG_UNKNOWN = CDIO_TRACK_FLAG_UNKNOWN;
32
+
33
+ %constant long int CDIO_CDROM_LBA = CDIO_CDROM_LBA;
34
+ %constant long int CDIO_CDROM_MSF = CDIO_CDROM_MSF;
35
+ %constant long int CDIO_CDROM_DATA_TRACK = CDIO_CDROM_DATA_TRACK;
36
+ %constant long int CDIO_CDROM_CDI_TRACK = CDIO_CDROM_CDI_TRACK;
37
+ %constant long int CDIO_CDROM_XA_TRACK = CDIO_CDROM_XA_TRACK;
38
+
39
+ %constant long int AUDIO = AUDIO;
40
+ %constant long int MODE1 = MODE1;
41
+ %constant long int MODE1_RAW = MODE1_RAW;
42
+ %constant long int MODE2 = MODE2;
43
+ %constant long int MODE2_FORM1 = MODE2_FORM1;
44
+ %constant long int MODE2_FORM2 = MODE2_FORM2;
45
+ %constant long int MODE2_FORM_MIX = MODE2_FORM_MIX;
46
+ %constant long int MODE2_RAW = MODE2_RAW;
47
+
48
+ %constant long int INVALID_TRACK = CDIO_INVALID_TRACK;
49
+ %constant long int CDROM_LEADOUT_TRACK = 0xAA;
50
+
51
+ typedef int track_flag_t;
52
+
53
+ %rename cdio_get_first_track_num get_first_track_num;
54
+ %feature("autodoc",
55
+ "get_first_track_num(p_cdio) -> int
56
+ Get the number of the first track.
57
+
58
+ return the track number or pycdio.INVALID_TRACK if there was
59
+ a problem.");
60
+ track_t cdio_get_first_track_num(const CdIo_t *p_cdio);
61
+
62
+ %rename cdio_get_last_track_num get_last_track_num ;
63
+ %feature("autodoc",
64
+ "get_last_track_num
65
+ Return the last track number.
66
+ pycdio.INVALID_TRACK is if there was a problem.");
67
+ track_t cdio_get_last_track_num (const CdIo_t *p_cdio);
68
+
69
+ %rename cdio_get_track get_track;
70
+ %feature("autodoc",
71
+ "cdio_get_track(lsn)->int
72
+
73
+ Find the track which contains lsn.
74
+ pycdio.INVALID_TRACK is returned if the lsn outside of the CD or
75
+ if there was some error.
76
+
77
+ If the lsn is before the pregap of the first track, 0 is returned.
78
+ Otherwise we return the track that spans the lsn.");
79
+ track_t cdio_get_track(const CdIo_t *p_cdio, lsn_t lsn);
80
+
81
+ %rename cdio_get_track_channels get_track_channels;
82
+ %feature("autodoc",
83
+ "get_track_channels(cdio, track)->int
84
+
85
+ Return number of channels in track: 2 or 4; -2 if implemented or -1
86
+ for error. Not meaningful if track is not an audio track.");
87
+ int cdio_get_track_channels(const CdIo_t *p_cdio, track_t i_track);
88
+
89
+ %rename cdio_get_track_copy_permit "track_copy_permit?";
90
+ %feature("autodoc",
91
+ "copy_permit?(cdio, track)->bool
92
+
93
+ Return copy protection status on a track. Is this meaningful
94
+ not an audio track?
95
+ ");
96
+ bool cdio_get_track_copy_permit(const CdIo_t *p_cdio, track_t i_track);
97
+
98
+ %feature("autodoc",
99
+ "get_track_format(cdio, track)->format
100
+
101
+ Get the format (audio, mode2, mode1) of track. ");
102
+ const char *get_track_format(const CdIo_t *p_cdio, track_t i_track);
103
+
104
+ %rename cdio_get_track_green "track_green?";
105
+ %feature("autodoc",
106
+ "track_green?(cdio, track) -> bool
107
+
108
+ Return True if we have XA data (green, mode2 form1) or
109
+ XA data (green, mode2 form2). That is track begins:
110
+ sync - header - subheader
111
+ 12 4 - 8
112
+
113
+ FIXME: there's gotta be a better design for this and get_track_format?");
114
+ bool cdio_get_track_green(const CdIo_t *p_cdio, track_t i_track);
115
+
116
+ %rename cdio_get_track_last_lsn get_track_last_lsn;
117
+ %feature("autodoc",
118
+ "cdio_get_track_last_lsn(cdio, track)->lsn
119
+
120
+ Return the ending LSN for track number
121
+ track in cdio. CDIO_INVALID_LSN is returned on error.");
122
+ lsn_t cdio_get_track_last_lsn(const CdIo_t *p_cdio, track_t i_track);
123
+
124
+ %rename cdio_get_track_lba get_track_lba;
125
+ %feature("autodoc",
126
+ "cdio_get_track_lba
127
+ Get the starting LBA for track number
128
+ i_track in p_cdio. Track numbers usually start at something
129
+ greater than 0, usually 1.
130
+
131
+ The 'leadout' track is specified either by
132
+ using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1.
133
+
134
+ @param p_cdio object to get information from
135
+ @param i_track the track number we want the LSN for
136
+ @return the starting LBA or CDIO_INVALID_LBA on error.");
137
+ lba_t cdio_get_track_lba(const CdIo_t *p_cdio, track_t i_track);
138
+
139
+ %rename cdio_get_track_lsn get_track_lsn;
140
+ %feature("autodoc",
141
+ "cdio_get_track_lsn (cdio, track)->int
142
+
143
+ Return the starting LSN for track number.
144
+ Track numbers usually start at something greater than 0, usually 1.
145
+
146
+ The 'leadout' track is specified either by
147
+ using i_track pycdio.CDROM_LEADOUT_TRACK or the total tracks+1.
148
+
149
+ pycdio.INVALID_LSN is returned on error.");
150
+ lsn_t cdio_get_track_lsn(const CdIo_t *p_cdio, track_t i_track);
151
+
152
+ %feature("autodoc",
153
+ "get_track_msf(cdio,track)->string
154
+
155
+ Return the starting MSF (minutes/secs/frames) for track number
156
+ track. Track numbers usually start at something
157
+ greater than 0, usually 1.
158
+
159
+ The 'leadout' track is specified either by
160
+ using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1.
161
+
162
+ @return string mm:ss:ff if all good, or string 'error' on error.");
163
+ char *get_track_msf(const CdIo_t *p_cdio, track_t i_track);
164
+ %inline %{
165
+ char *get_track_msf(const CdIo_t *p_cdio, track_t i_track)
166
+ {
167
+ msf_t msf;
168
+
169
+ if (!cdio_get_track_msf( p_cdio, i_track, &msf )) {
170
+ return NULL;
171
+ } else {
172
+ return cdio_msf_to_str( &msf );
173
+ }
174
+ }
175
+ %}
176
+
177
+ %rename cdio_get_track_preemphasis get_track_preemphasis;
178
+ %feature("autodoc",
179
+ "cdio_get_track_preemphasis(cdio, track)
180
+
181
+ Get linear preemphasis status on an audio track.
182
+ This is not meaningful if not an audio track?");
183
+ track_flag_t cdio_get_track_preemphasis(const CdIo_t *p_cdio, track_t i_track);
184
+
185
+ %rename cdio_get_track_sec_count get_track_sec_count;
186
+ %feature("autodoc",
187
+ "get_track_sec_count(cdio, track)->int
188
+
189
+ Get the number of sectors between this track an the next. This
190
+ includes any pregap sectors before the start of the next track.
191
+ Track numbers usually start at something
192
+ greater than 0, usually 1.
193
+
194
+ 0 is returned if there is an error.");
195
+ unsigned int cdio_get_track_sec_count(const CdIo_t *p_cdio, track_t i_track);
196
+
197
+ %inline %{
198
+ const char
199
+ *get_track_format(const CdIo_t *p_cdio, track_t i_track)
200
+ {
201
+ track_format_t track_format = cdio_get_track_format(p_cdio, i_track);
202
+ return track_format2str[track_format];
203
+ }
204
+ %}
205
+
206
+
data/swig/types.swg ADDED
@@ -0,0 +1,65 @@
1
+ /* -*- c -*-
2
+ $Id: types.swg,v 1.2 2006/12/03 00:20:03 rocky Exp $
3
+
4
+ Copyright (C) 2006 Rocky Bernstein <rocky@cpan.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ /*
22
+ Various typedef's "constant"s/variables
23
+
24
+ Many of these are documented more fully in libcdio's <cdio/types.h>
25
+ I'm not sure why, but including that directly will not allow
26
+ SWIG to understand say that a lsn_t is an int.
27
+ */
28
+
29
+ #ifdef NEED_LONG
30
+ #define LONG long
31
+ #else
32
+ #define LONG
33
+ #endif
34
+
35
+ #define uint32_t LONG unsigned int
36
+ #define uint16_t LONG unsigned int
37
+ #define int32_t LONG int
38
+ #define uint8_t unsigned char
39
+
40
+ typedef long int my_ssize_t;
41
+ typedef unsigned int driver_id_t;
42
+ typedef int lsn_t;
43
+ typedef int int16_t;
44
+ typedef int lba_t;
45
+ typedef unsigned int track_t;
46
+ typedef long int driver_return_code_t;
47
+ typedef long int ssize_t;
48
+ typedef unsigned int cdio_drive_read_cap_t;
49
+ typedef unsigned int cdio_drive_write_cap_t;
50
+ typedef unsigned int cdio_drive_misc_cap_t;
51
+
52
+ %constant long int VERSION_NUM = LIBCDIO_VERSION_NUM;
53
+
54
+ %constant long int INVALID_LBA = CDIO_INVALID_LBA;
55
+ %constant long int INVALID_LSN = CDIO_INVALID_LSN;
56
+
57
+ /* More documentation on the below is in cdio/sector.h */
58
+ %constant long int CD_FRAMESIZE = CDIO_CD_FRAMESIZE;
59
+ %constant long int CD_FRAMESIZE_RAW = CDIO_CD_FRAMESIZE_RAW;
60
+ %constant long int ISO_BLOCKSIZE = CDIO_CD_FRAMESIZE;
61
+ %constant long int M2F2_SECTOR_SIZE = M2F2_SECTOR_SIZE;
62
+ %constant long int M2RAW_SECTOR_SIZE = M2RAW_SECTOR_SIZE;
63
+
64
+ %typemap(out) bool
65
+ "$result = ($1 != 0) ? Qtrue : Qfalse;";
data/test/Makefile ADDED
@@ -0,0 +1,7 @@
1
+ #=============================================================
2
+ # $Id: Makefile,v 1.1 2006/11/18 18:40:33 rocky Exp $
3
+ #=============================================================
4
+ # Whatever it is you want to do, it should be handled by the
5
+ # by the main (parent) Makefile. So reissue make from there.
6
+ all %:
7
+ $(MAKE) -C .. $@
data/test/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ task :default => [:test]
2
+ # --------- Regression tests ------
3
+ require 'rake/testtask'
4
+ desc "Run regression tests"
5
+ Rake::TestTask.new('test') do |t|
6
+ t.pattern = '*.rb'
7
+ t.warning = true
8
+ end
data/test/cdda.bin ADDED
Binary file
data/test/cdda.cue ADDED
@@ -0,0 +1,7 @@
1
+ TITLE "Join us now we have the software"
2
+ CATALOG 0000010271955
3
+ PERFORMER "Richard Stallman"
4
+ FILE "BOING.BIN" BINARY
5
+ TRACK 01 AUDIO
6
+ FLAGS DCP
7
+ INDEX 01 00:00:00
data/test/cdda.toc ADDED
@@ -0,0 +1,14 @@
1
+ // $Id: cdda.toc,v 1.1 2006/11/18 18:40:59 rocky Exp $
2
+
3
+ // Language number should always start with 0
4
+ LANGUAGE 0 {
5
+ // Required fields - at least all CD-TEXT CDs I've seen so far have them.
6
+ TITLE "Join us now we have the software"
7
+ PERFORMER "Richard Stallman"
8
+ }
9
+ CATALOG "0000010271955"
10
+ CD_DA
11
+
12
+ TRACK AUDIO
13
+ COPY
14
+ FILE "cdda.bin" 00:00:00 00:00:00
data/test/cdiotest.rb ADDED
@@ -0,0 +1,228 @@
1
+ #!/usr/bin/env ruby
2
+ # $Id: cdiotest.rb,v 1.13 2006/12/16 03:44:48 rocky Exp $
3
+
4
+ # Unit test for cdio
5
+ #
6
+ require "test/unit"
7
+
8
+ Mypath = File.expand_path(File.dirname(__FILE__))
9
+ old_dir = File.expand_path(Dir.pwd)
10
+ if old_dir != Mypath
11
+ Dir.chdir(Mypath)
12
+ end
13
+ $: << Mypath + '/../ext/cdio'
14
+ $: << Mypath + '/../lib'
15
+ require "cdio"
16
+
17
+ class CdioTests < Test::Unit::TestCase
18
+
19
+ # Test running miscellaneous operations
20
+ # No assumption about the CD-ROM drives is made, so
21
+ # we're just going to run operations and see that they
22
+ # don't crash.
23
+ def test_ops()
24
+ device = Cdio::Device.new()
25
+ if Rubycdio::VERSION_NUM >= 76
26
+ # FIXME: Broken on Darwin?
27
+ # device.open()
28
+ device.ATAPI?()
29
+ # FIXME: Broken on Darwin?
30
+ # device.media_changed?
31
+ end
32
+ assert_equal(true, true, "Test misc operations")
33
+ end
34
+
35
+ # Test getting default device
36
+ def test_device_default()
37
+ result1=Cdio::default_device_driver(Rubycdio::DRIVER_DEVICE)
38
+ result2=Cdio::default_device_driver()
39
+ assert_equal(result1, result2,
40
+ "default_device with/out parameters")
41
+ device = Cdio::Device.new()
42
+ result2=device.device()
43
+ if result1:
44
+ assert_equal(result1[0], result2)
45
+ # Now try getting device using driver that we got back
46
+ begin
47
+ device=Cdio::Device.new(driver_id=result1[1])
48
+ result1 = device.device()
49
+ assert_equal(result1, result2,
50
+ "default_device using driver name")
51
+ rescue
52
+ end
53
+ end
54
+ end
55
+
56
+ # Test that various routines raise proper exceptions
57
+ def test_exceptions()
58
+ device = Cdio::Device.new()
59
+ # No CD or or CD image has been set yet. So these fail
60
+ begin
61
+ lsn = device.disc_last_lsn()
62
+ rescue IOError
63
+ assert_equal(true, true, "last_lsn() IO Error")
64
+ rescue Cdio::DriverError
65
+ assert_equal(true, true, "last_lsn() DriverError")
66
+ else
67
+ assert(false, "last_lsn() should raise error")
68
+ end
69
+ assert_equal("Uninitialized Device", device.disc_mode)
70
+ begin
71
+ track = device.num_tracks()
72
+ rescue IOError
73
+ assert_equal(true, true, "get_num_tracks() IO Error")
74
+ rescue Cdio::DriverError
75
+ assert_equal(true, true, "get_num_tracks() DriverError")
76
+ rescue Cdio::TrackError
77
+ assert_equal(true, true, "get_num_tracks() TrackError")
78
+ else
79
+ assert(false, "last_lsn() should raise error")
80
+ end
81
+ ## assert_raise(DriverUninitError, device.driver_name)
82
+ ## assert_raise(DriverUninitError,
83
+ ## device.media_changed)
84
+ ## assert_raise(IOError, device.open, "***Invalid device***")
85
+ end
86
+
87
+ # Test that we have image drivers
88
+ def test_have_image_drivers()
89
+ result = Cdio::driver? :"CDRDAO"
90
+ assert_equal(true, result, "Have cdrdrao driver via string")
91
+ result = Cdio::driver? Rubycdio::DRIVER_CDRDAO
92
+ assert_equal(true, result, "Have cdrdrao driver via driver_id")
93
+ result = Cdio::driver? :"NRG"
94
+ assert_equal(true, result, "Have NRG driver via string")
95
+ result = Cdio::driver? Rubycdio::DRIVER_NRG
96
+ assert_equal(true, result, "Have NRG driver via driver_id")
97
+ result = Cdio::driver? :'BIN/CUE'
98
+ assert_equal(true, result, "Have BIN/CUE driver via string")
99
+ result = Cdio::driver? Rubycdio::DRIVER_BINCUE
100
+ assert_equal(true, result, "Have BIN/CUE driver via driver_id")
101
+ end
102
+
103
+ # Test functioning of cdrdao image routines
104
+ def test_tocfile()
105
+ ## TOC reading needs to be done in the directory where the
106
+ ## TOC/BIN files reside.
107
+ olddir=Dir.pwd()
108
+ Dir.chdir(Mypath)
109
+ tocfile="cdda.toc"
110
+ device = Cdio::Device.new(tocfile, Rubycdio::DRIVER_CDRDAO)
111
+ hw = device.hwinfo()
112
+ assert_equal(true, hw != nil, "get_hwinfo ok")
113
+ assert_equal('libcdio', hw["vendor"], "get_hwinfo vendor")
114
+ assert_equal('cdrdao', hw["model"], "get_hwinfo cdrdao")
115
+ # Test known values of various access parameters:
116
+ # access mode, driver name via string and via driver_id
117
+ # and cue name
118
+ result = device.arg("access-mode")
119
+ assert_equal(result, 'image', 'get_arg("access_mode")')
120
+ result = device.driver_name()
121
+ assert_equal(result, 'CDRDAO', 'get_driver_name')
122
+ result = device.driver_id()
123
+ assert_equal(result, Rubycdio::DRIVER_CDRDAO, 'get_driver_id')
124
+ result = device.arg("source")
125
+ assert_equal(result, tocfile, 'get_arg("source")')
126
+ result = device.media_changed?
127
+ assert_equal(false, result, "tocfile: media_changed?")
128
+ # Test getting is_tocfile
129
+ result = tocfile?(tocfile)
130
+ assert_equal(true, result, "is_tocfile(tocfile)")
131
+ result = nrg? tocfile
132
+ assert_equal(false, result, "is_nrgfile(tocfile)")
133
+ result = device? tocfile
134
+ assert_equal(false, result, "is_device(tocfile)")
135
+ ## FIXME
136
+ ## assert_raise(DriverUnsupportedError,
137
+ ## (deviceblocksize= 2048))
138
+ ##assert_raise(DriverUnsupportedError,
139
+ ## (device.speed = 5))
140
+ device.close()
141
+ Dir.chdir(olddir)
142
+ end
143
+
144
+ # Test functioning of read routines
145
+ def test_read()
146
+ cuefile=Mypath + "/../data/isofs-m1.cue"
147
+ device = Cdio::Device.new(cuefile)
148
+ # Read the ISO Primary Volume descriptor
149
+ blocks, data=device.read_sectors(16, Rubycdio::READ_MODE_M1F1)
150
+ assert_equal(data[1..5], 'CD001')
151
+ assert_equal(blocks, 1)
152
+ blocks, data=device.read_data_blocks(26)
153
+ assert_equal(data[6..31], 'GNU GENERAL PUBLIC LICENSE')
154
+ end
155
+
156
+ # Test functioning of BIN/CUE image routines
157
+ def test_bincue()
158
+ cuefile= Mypath + "/cdda.cue"
159
+ device = Cdio::Device.new(source=cuefile)
160
+ # Test known values of various access parameters:
161
+ # access mode, driver name via string and via driver_id
162
+ # and cue name
163
+ result = device.arg("access-mode")
164
+ assert_equal(result, 'image', 'get_arg("access_mode")')
165
+ result = device.driver_name()
166
+ assert_equal(result, 'BIN/CUE', 'get_driver_name')
167
+ result = device.driver_id()
168
+ assert_equal(result, Rubycdio::DRIVER_BINCUE, 'get_driver_id')
169
+ result = device.arg("cue")
170
+ assert_equal(result, cuefile, 'get_arg("cue")')
171
+ # Test getting binfile? and cuefile?
172
+ binfile = cuefile? cuefile
173
+ assert_equal(true, binfile != nil, "cuefile? cuefile")
174
+ # require "debug"
175
+ cuefile2 = binfile? binfile
176
+ # Could check that cuefile2 == cuefile, but some OS's may
177
+ # change the case of files
178
+ assert_equal(true, cuefile2 != nil, "cuefile? binfile")
179
+ result = tocfile? cuefile
180
+ assert_equal(false, result, "tocfile? tocfile")
181
+ hw = device.hwinfo()
182
+ assert_equal(true, hw != nil, "get_hwinfo ok")
183
+ assert_equal('libcdio', hw["vendor"], "get_hwinfo vendor")
184
+ assert_equal('CDRWIN', hw["model"], "get_hwinfo model")
185
+ result = device? cuefile
186
+ assert_equal(false, result, "device? tocfile")
187
+ result = device.media_changed?
188
+ assert_equal(false, result, "binfile: media_changed?")
189
+ if Rubycdio::VERSION_NUM >= 77:
190
+ # There's a bug in libcdio 0.76 that causes these to crash
191
+ ### FIXME
192
+ ## assert_raise(DriverUnsupportedError,
193
+ ## device.blocksize= 2048)
194
+ ## assert_raise(DriverUnsupportedError,
195
+ ## device.speed = 5)
196
+ end
197
+ device.close()
198
+ end
199
+
200
+ # Test functioning CD-DA
201
+ def test_cdda()
202
+ device = Cdio::Device.new()
203
+ cuefile=Mypath + "/cdda.cue"
204
+ device.open(cuefile)
205
+ result = device.disc_mode()
206
+ assert_equal(result, 'CD-DA', 'get_disc_mode')
207
+ assert_equal(device.mcn(), '0000010271955', 'get_mcn')
208
+ ## FIXME
209
+ ## assert_raise(DriverUnsupportedError,
210
+ ## device.last_session)
211
+ # assert_raise(IOError, device.joliet_level)
212
+ result = device.num_tracks()
213
+ assert_equal(result, 1, 'get_num_tracks')
214
+ disc_last_lsn = device.disc_last_lsn()
215
+ assert_equal(disc_last_lsn, 302, 'get_disc_last_lsn')
216
+ t=device.last_track()
217
+ assert_equal(t.track, 1, 'last_track')
218
+ assert_equal(t.last_lsn(), 301, '(track) last_lsn')
219
+ assert_equal(device.track_for_lsn(t.last_lsn()).track,
220
+ t.track)
221
+ t=device.first_track()
222
+ assert_equal(t.track, 1, 'get_first_track')
223
+ assert_equal(t.format(), 'audio', 'get_track_format')
224
+ assert_equal(t.msf(), "00:02:00", "get_msf")
225
+ device.close()
226
+ end
227
+ end
228
+ Dir.chdir(old_dir)