aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2020-05-09 19:16:13 -0400
committerB. Watson <yalhcru@gmail.com>2020-05-09 19:16:13 -0400
commit092c409ab70d2c34d87af998d859e2019059131a (patch)
tree61835153e0afa71e750241d3e1b9c1e97cbd938b
parent8dda4bc4f4fdb5d79af90022d44cd0e568b84899 (diff)
downloadmiragextract-092c409ab70d2c34d87af998d859e2019059131a.tar.gz
autodetect mac .dmg data tracks
-rw-r--r--FAQ21
-rw-r--r--miragextract.18
-rw-r--r--miragextract.c9
-rw-r--r--miragextract.html8
-rw-r--r--miragextract.rst10
5 files changed, 27 insertions, 29 deletions
diff --git a/FAQ b/FAQ
index 09ccfc3..2a6c58e 100644
--- a/FAQ
+++ b/FAQ
@@ -29,22 +29,21 @@ just to listen to the audio tracks. You can use it for anything you want
(it's licensed WTFPL, so that means *anything*).
Q4. Why is there no '-f mp3' option?
-A4. Because I use libsndfile to write the audio files, and its developer
-has chosen not to include mp3 support. If you really need mp3 (if ogg and/or
-flac just won't satisfy you), you can always convert to wav and use any
-mp3 converter (lame, ffmpeg, etc). Someday I may actually add lame support
-to miragextract, but don't hold your breath.
+A4. Because miragextract uses libsndfile to write the audio files,
+and its developer has chosen not to include mp3 support. If you really
+need mp3 (if ogg and/or flac just won't satisfy you), you can always
+convert to wav and use any mp3 converter (lame, ffmpeg, etc). Someday I
+may actually add lame support to miragextract, but don't hold your breath.
Q5. Why do my extracted audio tracks sound like white noise?
A5. Try the -s flag. If you're on a big-endian platform and you have this
issue, I'd like to hear from you (email address found in README).
-Q6. This track01.iso I just extracted isn't an ISO, it's a Macintosh DMG.
-How come it's got .iso in the filename?
-A6. There's no way for miragextract to tell what type of image a data
-track actually contains. Adding support for this would be possible,
-but it's not there yet. Currently, the file will get called .iso because
-that's what most images contain. Just rename it if it's wrong.
+Q6. This track01.iso I just extracted isn't an ISO, it's something
+else. How come it's got .iso in the filename?
+A6. Just rename it. miragextract doesn't have extensive file-type checking.
+Currently, if it looks like an Apple disk image, it'll get named .dmg,
+otherwise it's assumed to be a .iso.
Q7. I built a static binary of miragextract, but it fails (or still requires
shared libraries). Why?
diff --git a/miragextract.1 b/miragextract.1
index a1842aa..bad5f7c 100644
--- a/miragextract.1
+++ b/miragextract.1
@@ -67,7 +67,7 @@ also the \-n option.
Extract only data tracks. Default is to extract all tracks.
.TP
.B \-f
-Sets the format and filename extension for the output files.
+Sets the format and filename extension for the output audio files.
Choices are \fBwav\fP, \fBogg\fP, \fBflac\fP, \fBcdda\fP (raw CD audio). Default is \fBwav\fP\&.
.TP
.B \-l
@@ -114,10 +114,8 @@ match the encoding set with \-f. Note that mp3 is NOT a valid \-f option.
If you need mp3, extract to .wav and then use a tool like lame or ffmpeg
to convert to mp3.
.sp
-Output data tracks will be named to end in \(aq.iso\(aq, which is usually
-correct. Future versions of this program might be smart enough to
-detect e.g. Macintosh DMG files and name them appropriately (for now,
-just rename them if you need to).
+Output data tracks will be named to end in \(aq.iso\(aq, or \(aq.dmg\(aq if they look
+like Apple disk images.
.sp
Images with multiple sessions should be supported, but have not been
tested. Track numbering just continues, so a disc with 2 sessions of
diff --git a/miragextract.c b/miragextract.c
index 8e80529..02325ae 100644
--- a/miragextract.c
+++ b/miragextract.c
@@ -134,8 +134,14 @@ void process_track(int t, int extract) {
break;
}
- if(!(sector = mirage_track_get_sector(track, 0, 0, &gerr)))
+ /* examine first sector, see if it's got Apple magic */
+ sec = mirage_track_get_track_start(track);
+ if(!(sector = mirage_track_get_sector(track, sec, 0, &gerr)))
+ die(NULL);
+ if(!(mirage_sector_get_data(sector, &buf, &len, &gerr)))
die(NULL);
+ if(buf[0] == 'E' && buf[1] == 'R' && buf[3] == 0 && (buf[2] == 0x02 || buf[2] == 0x08))
+ ext = "dmg";
sprintf(outfile, "%s%02d.%s", outfilebase, output_track_number, ext);
@@ -170,7 +176,6 @@ void process_track(int t, int extract) {
}
}
- sec = mirage_track_get_track_start(track);
while((sector = mirage_track_get_sector(track, sec++, 0, NULL))) {
if(!(mirage_sector_get_data(sector, &buf, &len, &gerr)))
die(NULL);
diff --git a/miragextract.html b/miragextract.html
index 3fe03ad..4066fbb 100644
--- a/miragextract.html
+++ b/miragextract.html
@@ -416,7 +416,7 @@ also the -n option.</td></tr>
<td>Extract only data tracks. Default is to extract all tracks.</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-f</span></kbd></td>
-<td>Sets the format and filename extension for the output files.
+<td>Sets the format and filename extension for the output audio files.
Choices are <strong>wav</strong>, <strong>ogg</strong>, <strong>flac</strong>, <strong>cdda</strong> (raw CD audio). Default is <strong>wav</strong>.</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-l</span></kbd></td>
@@ -461,10 +461,8 @@ by libmirage. See the README for your version of libmirage for details.</p>
match the encoding set with -f. Note that mp3 is NOT a valid -f option.
If you need mp3, extract to .wav and then use a tool like lame or ffmpeg
to convert to mp3.</p>
-<p>Output data tracks will be named to end in '.iso', which is usually
-correct. Future versions of this program might be smart enough to
-detect e.g. Macintosh DMG files and name them appropriately (for now,
-just rename them if you need to).</p>
+<p>Output data tracks will be named to end in '.iso', or '.dmg' if they look
+like Apple disk images.</p>
<p>Images with multiple sessions should be supported, but have not been
tested. Track numbering just continues, so a disc with 2 sessions of
8 files each will have tracks numbered 1 to 16 as far as the -t option
diff --git a/miragextract.rst b/miragextract.rst
index b2cb9ff..9ac2048 100644
--- a/miragextract.rst
+++ b/miragextract.rst
@@ -48,7 +48,7 @@ OPTIONS
-d Extract only data tracks. Default is to extract all tracks.
--f Sets the format and filename extension for the output files.
+-f Sets the format and filename extension for the output audio files.
Choices are **wav**, **ogg**, **flac**, **cdda** (raw CD audio). Default is **wav**.
-l Lists the tracks in the image without extracting them.
@@ -60,7 +60,7 @@ OPTIONS
have permission to write there.
-p Password for encrypted images. Note that anyone who can run **ps(1)**
- on your system can view the password. Also note that password
+ on your system may be able to view the password. Also note that password
support in miragextract is *completely* untested: I have no
encrypted images to test with.
@@ -90,10 +90,8 @@ match the encoding set with -f. Note that mp3 is NOT a valid -f option.
If you need mp3, extract to .wav and then use a tool like lame or ffmpeg
to convert to mp3.
-Output data tracks will be named to end in '.iso', which is usually
-correct. Future versions of this program might be smart enough to
-detect e.g. Macintosh DMG files and name them appropriately (for now,
-just rename them if you need to).
+Output data tracks will be named to end in '.iso', or '.dmg' if they look
+like Apple disk images.
Images with multiple sessions should be supported, but have not been
tested. Track numbering just continues, so a disc with 2 sessions of