This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Email bug reports to: flipflop7146@yahoo.com

Many, many thanks to the guys on AVS Forum for all of the info on
the filesystem structures.
Especially to wolfgang, videodude, vbcoder, toots, steve d, seanriddle
(in reverse alphabetical order)

Thanks to Rod Hewitt for providing the patch to insert the system header
and program stream map into extracted MPEG files.

Thanks to Shahed Ameer for providing the patch to extract unlinked (deleted)
files, and for the brief/verbose program description options.

USAGE: extract_rtv <devicename> <options>
  -l            directory listing
  -d            show program descriptions (brief)
  -dv           show program descriptions (verbose)
  -da           show ALL (incl. deleted) descriptions (brief)
  -dd           show ALL (incl. deleted) descriptions (verbose)
  -e            extract all files
  -e filename   extract single file or subdirectory
  -b NNNN       set read buffer size (default=128)
  -p            device file is a partition
  -pN           use partition N (N=1,2,3,4)
  -r cluster#   restore unlinked/lost file at this cluster
  -u            look for unlinked (deleted) files
  -v            verify drive integrity
  -w filename localfile
                overwrite filename with localfile

If you omit <devicename>, extract_rtv will attempt to
autodetect the ReplayTV device connected to your system.

Examples:

In Linux, use:
  /dev/hda   Primary Master
  /dev/hdb   Primary Slave
  /dev/hdc   Secondary Master
  /dev/hdd   Secondary Slave

In Windows2000 use:
  \\.\PhysicalDrive0     First hard drive
  \\.\PhysicalDrive1     Second hard drive
  \\.\PhysicalDrive2     Third hard drive
  \\.\PhysicalDrive3     Fourth hard drive

You can also use an image file by specifying the name of the
image file.  For example: extract_rtv drive.image -v

Validate filesystem integrity of the first partition:
 extract_rtv -p1 -v

List all files on the first partition:
 extract_rtv -p1 -l

Extract all files on the first partition to the current directory:
 extract_rtv -p1 -e

Show the brief descriptions of the *.mpg files:
 extract_rtv -d

Extract a single file from the second partition
to the current directory:
 extract_rtv -p2 -e 971351356.mpg

Extract a subdirectory's contents to the current directory:
 extract_rtv -p1 -e sys1

Extract a deleted file from the second partition
 extract_rtv -dd           (look to find the .mpg file name)
 extract_rtv -p2 -u        (look to find the cluster number for that file)
 extract_rtv -p2 -r 12345  (12345 is the cluster number of the lost file)

Overwrite the sys1/etc/StartupScript.Sutter3 file on the ReplayTV with the
StartupScript.Sutter from the local directory:
WARNING: This is a very risky operation.  Make sure you have a complete
backup, and know what you are doing before attempting this.  Writing files
to your ReplayTV could easily turn it into a brick.  You have been warned!!!
 extract_rtv /dev/hdc -w sys1/etc/StartupScript.Sutter3 StartupScript.Sutter3

You can overwrite existing files, you cannot currently create any new files.

