Extracting Files
Files can be extracted with the extract command. It takes the name of an archive and a list of files and directories as arguments:
cp2 extract fileconv/test-files.sdk Docs:sample.text Code:ZIPPY
extracting Docs/sample.text extracting Code/ZIPPY
If you give it a directory name, all files in that directory will be extracted. If you don't provide a list of files to extract at all, then all files in the archive will be extracted:
cp2 extract fileconv/test-files.sdk
extracting Graphics/WORLD.MAP.PIC extracting Graphics/MONARCH extracting Graphics/TEST.DHR [... many more ...]
By default, files are extracted with their directory structure intact. If you would prefer to have files extracted to the current directory, you can add the --strip-paths option:
cp2 extract --strip-paths fileconv/test-files.sdk Docs:sample.text
extracting Docs/sample.text -> sample.text
As with commands, some options have short aliases that can be given with a single hyphen instead of a double hyphen. The above command could have been written "cp2 x -j fileconv/test-files.sdk Docs:sample.text" instead ('j' is short for "junk paths").
Filename comparisons are always case-insensitive.
Attribute Preservation
Files may have resource forks, file types, dates, and access flags that should be preserved. CiderPress II supports multiple preservation schemes. A simple approach, which should be familiar to users of the original CiderPress, is called NAPS (NuLib2 Attribute Preservation String). It adds a string to the end of the filename to store the ProDOS or HFS type information, and appends an 'r' for resource forks. For example, suppose we wanted to extract an Apple IIgs Teach document:
cp2 x --preserve=naps fileconv/test-files.sdk Docs/TeachTest
extracting Docs/TeachTest -> Docs\TeachTest#505445 extracting Docs/TeachTest (rsrc) -> Docs\TeachTest#505445r
Note there are two files, one for each fork. The "hash tag" string includes the ProDOS file type ($50) and auxtype ($5445). The file's modification date has been set according to the value stored in the disk image, and the file's read-only flag was set if the file was locked.
You can also extract files to AppleSingle, AppleDouble, or (on Mac OS) use the host filesystem to store the resource fork and extended attributes. The preservation mode can be set with --preserve or the shorter -p flag. For example, to extract as AppleDouble:
cp2 x -pd fileconv/test-files.sdk Docs/TeachTest
extracting Docs/TeachTest extracting Docs/TeachTest (rsrc) -> Docs\._TeachTest
Use -pa for AppleSingle, -pd for AppleDouble, -pn for NAPS, -ph for host filesystem (Mac OS only), or -p0 for no preservation (the default).
Selection With Wildcards
You can reference files in an archive with wildcards. The asterisk (*) character matches multiple characters, and the question mark (?) matches a single character. For example:
cp2 extract fileconv/test-files.sdk "Graphics/*.HR"
extracting Graphics/BARS.HR extracting Graphics/MULTICOLOR.HR
Another example, showing multiple wildcards and short options:
cp2 x -jpn fileconv/test-files.sdk "Graphics/*/*.320?"
extracting Graphics/SHR/ROSE.3200 -> ROSE.3200#c08005 extracting Graphics/SHR/EAGLE.3200 -> EAGLE.3200#c00002 extracting Graphics/SHR/DG.3200 -> DG.3200#060000 extracting Graphics/SHR/ASTRO.3201 -> ASTRO.3201#060000
It's important to put arguments with wildcards in quotes, so that the command shell doesn't try to match them against files in the current directory.
Using Ext-Archive
When working with filesystems on disk images,
you can specify the base directory to use when extracting files by adding the
partial path to the archive name. Suppose we wanted to extract the contents of
the Graphics/SHR
directory, and we wanted all of the files to end up in
an SHR
subdirectory of the directory we're running the command in.
Specifying "Graphics/SHR/*"
would extract the files into the
Graphics/SHR
directory, which we don't want, but
removing the paths with --strip-paths
would also remove SHR
.
Instead, we can tell it to extract the entire SHR
directory, treating
the Graphics
directory as the root:
cp2 x fileconv/test-files.sdk:Graphics SHR
extracting Graphics/SHR/ROSE.3200 -> SHR\ROSE.3200 extracting Graphics/SHR/EAGLE.3200 -> SHR\EAGLE.3200 extracting Graphics/SHR/DG.3200 -> SHR\DG.3200 [... more ...]