|
|
|||||||||||||||
Introduction to CabarcCabarc is a utility that creates, extracts, and lists the contents of cabinet (.cab) files. Cabarc uses a command-line interface similar to that of popular archiving tools. Cabarc supports wildcards and recursive directory searches. The cabinet format is an efficient way to package multiple files. The cabinet format has two key features: multiple files can be stored in a single cabinet (.cab) file, and data compression is performed across file boundaries, which significantly improves the compression ratio. Cabinet file construction can be designed around the number of files to be compressed and the expected patterns for gaining access to them (sequential, random, all at once, or a few at a time). A key concept of the cabinet file is the folder. A folder is a collection of one or more compressed files that are compressed together as a single entity. Compressing files this way improves the compression ratio. Random access time suffers, however, because decoding (decompressing) any file in a folder requires that all preceding files in that folder must also be decoded. The focus is on maximum compression as opposed to quick decompression, since the cabinet format is designed to deliver file content, rather than to stream media. The dubuild utility is an alternative to cabarc when distributing software using Microsoft® Internet Explorer 4.0. The dubuild utility creates Distribution Units that are installed using the Java Language Package Manager. For more information, see Using DUBuild and Java Package Management and Code Download. Using Cabinets With Java FilesThere are two reasons to use the cabinet technology with Java classes. The first is building Java applets with lots of classes and graphics or audio files that you would like compressed and that would not be shared by other sites. This group is referred to here as the "applet" group, referring to the <APPLET> HTML tag that is used to access the contents of the cabinet file. The second reason is to distribute your Java class libraries to users so that your classes can be accessed like system classes by Java applets or applications. HTML pages that download cabinets containing library files use the <OBJECT> tag to download and access the libraries. Note that the library scheme only supports the download and access of class files, not images or audio. These files should be provided by the applet and not the cabinet file. Archiving Applets and Multimedia FilesThis procedure will help you create a cabinet file for delivering compressed class and multimedia files to a user's system.
When creating cabinets that will be read by the browser from the CABBASE parameter, make sure to use the default compression mode (MSZIP) and not the new LZX (Lempel-Ziv) compression mode, which is not supported by Internet Explorer 3.xx, but is supported by Internet Explorer version 4.0). Archiving Library FilesWhen delivering libraries in a cabinet file, the files to be compressed and delivered are archived in one cabinet file called the inner cabinet. This file is itself archived in another cabinet file (called the outer cabinet) with an .inf file. The .inf file, based on the Master.inf template found in the SDK-Java\Bin directory, is used by the setup engine in Internet Explorer. It contains the names of the libraries, where the libraries should be placed, the class identifier used in the <OBJECT> tag, and so on. The use of the .inf file only pertains to libraries, which are referenced by using the <OBJECT> HTML and does not pertain to applets. Information for the Master.inf TemplateFor Java libraries, you will need to gather the following information to fill out the .inf file copied from the Master.inf template (found in the SDK-Java\Bin directory).
Should you want to, you can also include the following information.
Instructions for Building Cabinet Files for LibrariesThe following steps will help you create a cabinet file for installing Java libraries on a user's computer.
Accessing the Cabinet From a Web PageFor Java applets, you use the CABBASE parameter in an APPLET tag to point to the .cab file. If the applet is not already present on the user's system, the .cab file is downloaded, the contents are extracted, and the applet is started. To use the APPLET tag, you set the parameters as shown in the following example. <APPLET CODE="sample.class" WIDTH=100 HEIGHT=100> <PARAM NAME="cabbase" VALUE="vendor.cab"> </APPLET> Using the CABBASE parameter does not conflict with CODEBASE or any other parameters necessary for other browsers. Using CABBASE along with the other tags allows Internet Explorer 3.0 and other cabinet file-supporting browsers to use .cab files without impeding the ability of other browsers to download and execute applets. For Java libraries, you use the OBJECT tag to point to the .cab file. If the classes (in the current version) are not already present on the user's system, the .cab file is downloaded, and the contents are extracted and placed in the appropriate location on the user's system. This step should be done according to following syntax. <OBJECT CLASSID="<classid>" CODEBASE="<path to cab>#Version=x,x,x,x"> </OBJECT> For example, <OBJECT CLASSID="clsid:12345678-9abc-def1-1234567890ab" CODEBASE="cabs/vendor.cab#Version=1,0,0,12"> </OBJECT> As in the preceding example, the CODEBASE attribute can specify a version number, which enables the libraries to be downloaded and installed if the version on the user's system is out-of-date. Both the ClassId and the version number are also stored in the .inf file inside the outer cabinet file. Including the version number is optional but highly recommended. This step permanentlyinstalls the classes on the user's system, so only use this for libraries. After libraries are installed in this manner, APPLET tags can refer to the classes placed in the library specified by Cabs/Vendor.cab. Those applets work like normal, with classes brought in through CABBASE or CODEBASE. Using the Cabarc UtilityCabinets are created by using the n command, which is followed first by the name of the cabinet to create and then by a filename list. This is shown in the following example. cabarc n mycab.cab prog.c prog.h prog.exe readme.txt The previous command creates the cabinet Mycab.cab containing the files Prog.c, Prog.h, Prog.exe, and Readme.txt in a single folder by using the default compression mode, MSZIP. Command Line UsageCabarc is used as follows. cabarc [<options>] <command> [<file list>] Three commands are currently supported: n (creates a new cabinet), l (lists the contents of an existing cabinet), and x (extracts files from a cabinet). These commands are described later in this document. Using WildcardsCabarc supports wildcards in the filename list, as shown in the example below. cabarc n mycab.cab prog.* readme.txt Creating FoldersAll files are added to a single folder (compression history) in the cabinet. It is possible to instruct cabarc to begin a new folder by using the plus sign (+) for the file to be added, as shown in the following example. cabarc n mycab.cab test.c main.c + test.exe *.obj The previous command creates the cabinet mycab.cab with one folder containing test.c and main.c and a second folder containing test.exe and all files matching *.obj. Preserving Directory PathsBy default, directory names are not preserved in the cabinetonly the filename component is stored. For example, the following command stores prog.c in the cabinet. cabarc n mycab.cab c:\source\myproj\prog.c To preserve paths, use the -p option as shown in the following example. cabarc -p n mycab.cab c:\mysource\myproj\prog.c This command puts mysource\myproj\prog.c in the cabinet. Be aware that the c:\ prefix is still stripped from the filename. Cabarc will not enable absolute paths to be stored in the cabinet, nor will it extract such absolute paths. Stripping PathsPath stripping is an option that preserves part of a path name. The following example shows how the path stripping option can archive everything in the c:\mysource\myproj\ directory but store only the myproj\ component of the path. cabarc -p -P mysource\ n mycab.cab c:\mysource\myproj\prog.c The -P option strips any strings that begin with the string provided. Be aware that wildcards are not supported by the -P option, which is a simple text match. Absolute path prefixes, such as c:\ or \, are stripped before the comparison takes place. Do not include absolute path prefixes when using the -P option. The -P option may be used more than once to strip out multiple paths. Cabarc builds a list of all paths to be stripped and applies only the first one that matches. Consider the following example. cabarc -p -P mysrc\ -P yoursrc\ n mycab.cab c:\mysrc\myproj\*.* d:\yoursrc\yourproj\*.c The trailing slash at the end of the path name is important. Entering -P mysrc instead of -P mysrc\ would cause files to be added as \myproj\<filename>. Using Recursive Directory SearchCabarc can archive files in a directory and all of its subdirectories by using the -r option. For example, the following command example archives all files ending in .h that are in c:\msdev\include\, c:\msdev\include\sys, and c:\msdev\include\gl (assuming these directories exist on your system). cabarc -r -p n mycab.cab c:\msdev\include\*.h The -p option is used here to preserve the path information when the files are added to the cabinet. Without this option, only the filename components would be stored, although sometimes it might be desirable behavior to not use -p. Reserving Space for Code SignatureCabarc can reserve space in the cabinet for a code signature. This is done with the -s option, which reserves a specified amount of empty space in the cabinet. For code signatures, reserve 6144 bytes. Consider the following example for doing so. cabarc -s 6144 n mycab.cab test.exe Be aware that the -s option does not actually write the code signature; it merely reserves space for it in the cabinet. Use the appropriate code signing utility to fill out the code signature. Setting the Cabinet IDCabinet files have a 16-bit cabinet ID field that is designed for application use. The default value of this field is zero; however, use the -i option of cabarc to set this field to any 16-bit value. Consider the following example. cabarc -i 12345 n mycab.cab test.exe Setting the Compression TypeSet the compression type with the -m option. The default compression type for a cabinet is MSZIP . The three supported compression modes are MSZIP compression (-m MSZIP), no compression (-m NONE), and LZX compression. LZX compression is selected by -m LZX:<w> where <w> is a number in the 15 to 21 range denoting the size of the compression history window, 2 to the power of <w>. A larger history window requires more memory when compressing or decompressing, but it provides better compression. LZX compression must not be used when creating cabinets that will be read by the browser from the CABBASE parameterInternet Explorer 3.xx does not support the LZX compression mode. However, Internet Explorer version 4.0 does. The following command stores files in the cabinet with MSZIP compression. cabarc -m MSZIP n mycab.c *.* Using a File List from a FileCabarc can input its list of files from a text file instead of from the command line by using the @file option followed by the name of the file from which to take the inputs. Consider the following example. cabarc n mycab.cab @file filelist.txt The text file must list the physical filenames of the files to be added, one per line. As is the case when specifying filenames on the command line, the plus sign (+) can be used as a filename to specify the beginning of a new folder. If a filename contains any embedded spaces, it must be enclosed as quotes, as follows. test.c myapp.exe "output file.exe" Quotation marks are required because each physical filename can be followed (on the same line) by an optional logical filename, which specifies the name under which the file will be stored in the cabinet. Consider the following example. test.c myapp.c myapp.exe "output file.exe" myfile.exe If the logical filename contains spaces, it also must be enclosed in quotation marks. Note that the logical filename overrides the -p (preserve path names) and -P (strip path name) options; the file is added to the cabinet exactly as indicated. Wildcards can be used in the physical filename, but in this situation, a logical filename is not allowed. The @file option can be used more than once to retrieve file lists from multiple files. Cabarc does not check for the presence of duplicate files, so if the same physical file appears in more than one file list, the file will be added to the cabinet as often as needed. The @file option can be combined with filenames on the command line. The files from the use of -l option are added first. Consider the following example. cabarc -l filelist1.txt -l filelist2.txt n mycab.cab *.c *.h Note that the @file option is available only when creating cabinets, not when extracting or listing cabinets. Listing Cabinet ContentsIt is possible to view the contents of a cabinet using the l (list) command, as shown below. cabarc l mycab.cab Cabarc displays the cabinet identifier in the cabinet. (See the -s option for cabinet creation.) Cabarc also displays the following file information: size, date, time, and attributes. Extracting Files from CabinetsThe x (extract) command extracts files from a cabinet. The simplest use of the X command is shown in the following example, which extracts all files from the cabinet. cabarc x mycab.cab Alternatively, it is possible to extract files selectively by providing a list of filenames, wildcards, or both. cabarc x mycab.cab readme.txt *.exe *.c Full path names (if they are present in the cabinet) are not preserved upon extraction by default. For example, if a file named mysrc\myproj\test.c is present in the cabinet, the command cabarc x mycab.cab will cause the file test.c to be extracted into the current directory. To preserve filenames upon extraction, the -p option must be used. The -p option causes any required directories to be created, if necessary. Only the filename component is considered in the matching process. The path name is ignored. For example, the command "cabarc x mycab.cab test.c" causes the file mysrc\myproj\test.c to be extracted to the current directory as test.c, as will cabarc x mycab.cab *.c (which also extracts any other files matching *.c). By default, the extracted files are stored in the current directory (and its subdirectories, if the -p option is used). However, it is possible to specify a destination directory for the extracted files. This is accomplished by appending a directory name to the command line. The directory name must end in a backslash (\). Consider the following examples. cabarc x mycab.cab c:\somedir\ cabarc x mycab.cab *.exe c:\somedir\
|
© 1998 Microsoft Corporation. All rights reserved. Terms of use. |