2 * Copyright 1997 Victor Schneider
3 * Copyright 2002 Alexandre Julliard
4 * Copyright 2007 Hans Leidekker
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_LEAN_AND_MEAN
29 static UINT CALLBACK extract_callback( PVOID context, UINT notification, UINT_PTR param1, UINT_PTR param2 )
31 FILE_IN_CABINET_INFO_A *info = (FILE_IN_CABINET_INFO_A *)param1;
35 case SPFILENOTIFY_FILEINCABINET:
37 LPCSTR targetname = context;
39 strcpy( info->FullTargetName, targetname );
42 default: return NO_ERROR;
46 int main(int argc, char *argv[])
49 char infile[MAX_PATH], outfile[MAX_PATH], actual_name[MAX_PATH];
54 fprintf( stderr, "Usage: %s infile outfile\n", argv[0] );
58 GetFullPathNameA( argv[1], sizeof(infile), infile, NULL );
59 GetFullPathNameA( argv[2], sizeof(outfile), outfile, NULL );
61 if (!lstrcmpiA( infile, outfile ))
63 fprintf( stderr, "%s: can't expand file to itself\n", argv[0] );
66 if (!SetupGetFileCompressionInfoExA( infile, actual_name, sizeof(actual_name), NULL, NULL, NULL, &comp ))
68 fprintf( stderr, "%s: can't open input file %s\n", argv[0], infile );
74 case FILE_COMPRESSION_MSZIP:
76 if (!SetupIterateCabinetA( infile, 0, extract_callback, (PVOID)outfile ))
78 fprintf( stderr, "%s: cabinet extraction failed\n", argv[0] );
83 case FILE_COMPRESSION_WINLZA:
89 if ((hin = LZOpenFile( infile, &ofin, OF_READ )) < 0)
91 fprintf( stderr, "%s: can't open input file %s\n", argv[0], infile );
94 if ((hout = LZOpenFile( outfile, &ofout, OF_CREATE | OF_WRITE )) < 0)
97 fprintf( stderr, "%s: can't open output file %s\n", argv[0], outfile );
100 error = LZCopy( hin, hout );
107 fprintf( stderr, "%s: LZCopy failed, error is %d\n", argv[0], error );
114 if (!CopyFileA( infile, outfile, FALSE ))
116 fprintf( stderr, "%s: CopyFileA failed\n", argv[0] );