2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: Test program for cabinet classes
4 * FILE: apps/cabman/test.cpp
5 * PURPOSE: Test program
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * CSH 21/03-2001 Created
21 DWORD DebugTraceLevel
= MIN_TRACE
;
22 //DWORD DebugTraceLevel = MID_TRACE;
23 //DWORD DebugTraceLevel = MAX_TRACE;
32 * FUNCTION: Default constructor
35 PromptOnOverwrite
= FALSE
;
41 * FUNCTION: Default destructor
47 VOID
CCABTest::ExtractFromCabinet()
49 * FUNCTION: Extract file(s) from cabinet
55 if (Open() == CAB_STATUS_SUCCESS
) {
56 printf("Cabinet %s\n\n", GetCabinetName());
58 if (FindFirst("", &Search
) == CAB_STATUS_SUCCESS
) {
60 switch (Status
= ExtractFile(Search
.FileName
)) {
61 case CAB_STATUS_SUCCESS
:
63 case CAB_STATUS_INVALID_CAB
:
64 printf("Cabinet contains errors.\n");
66 case CAB_STATUS_UNSUPPCOMP
:
67 printf("Cabinet uses unsupported compression type.\n");
69 case CAB_STATUS_CANNOT_WRITE
:
70 printf("You've run out of free space on the destination volume or the volume is damaged.\n");
73 printf("Unspecified error code (%d).\n", (UINT
)Status
);
76 } while (FindNext(&Search
) == CAB_STATUS_SUCCESS
);
79 printf("Cannot not open file: %s.\n", GetCabinetName());
86 BOOL
CCABTest::OnOverwrite(PCFFILE File
,
89 * FUNCTION: Called when extracting a file and it already exists
91 * File = Pointer to CFFILE for file being extracted
92 * Filename = Pointer to buffer with name of file (full path)
94 * TRUE if the file should be overwritten, FALSE if not
99 /* Should we prompt on overwrite? */
100 if (!PromptOnOverwrite
)
103 /* Ask if file should be overwritten */
104 printf("Overwrite %s (Yes/No/All)? ", GetFileName(FileName
));
110 case 'y': printf("%c\n", ch
); return TRUE
;
112 case 'n': printf("%c\n", ch
); return FALSE
;
114 case 'a': printf("%c\n", ch
); PromptOnOverwrite
= FALSE
; return TRUE
;
120 VOID
CCABTest::OnExtract(PCFFILE File
,
123 * FUNCTION: Called just before extracting a file
125 * File = Pointer to CFFILE for file being extracted
126 * FileName = Pointer to buffer with name of file (full path)
129 printf("Extracting %s\n", GetFileName(FileName
));
134 VOID
CCABTest::OnDiskChange(LPTSTR CabinetName
,
137 * FUNCTION: Called when a new disk is to be processed
139 * CabinetName = Pointer to buffer with name of cabinet
140 * DiskLabel = Pointer to buffer with label of disk
143 printf("\nChanging to cabinet %s - %s\n\n", CabinetName
, DiskLabel
);
147 INT
main(INT argc
, PCHAR argv
[])
149 * FUNCTION: Main entry point
151 * argc = Number of arguments on command line
152 * argv = Pointer to list of command line arguments
157 // Specify your cabinet filename here
158 CABTest
.SetCabinetName("ros1.cab");
159 CABTest
.ExtractFromCabinet();