2 * Extract - Wine-compatible program for extract *.cab files.
4 * Copyright 2007 Etersoft (Lyutin Anatoly)
5 * Copyright 2009 Ilya Shpigor
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/unicode.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(extrac32);
31 static UINT WINAPI ExtCabCallback(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2)
33 FILE_IN_CABINET_INFO_W *pInfo;
34 FILEPATHS_W *pFilePaths;
38 case SPFILENOTIFY_FILEINCABINET:
39 pInfo = (FILE_IN_CABINET_INFO_W*)Param1;
40 lstrcpyW(pInfo->FullTargetName, (LPCWSTR)Context);
41 lstrcatW(pInfo->FullTargetName, pInfo->NameInCabinet);
43 case SPFILENOTIFY_FILEEXTRACTED:
44 pFilePaths = (FILEPATHS_W*)Param1;
45 WINE_TRACE("Extracted %s\n", wine_dbgstr_w(pFilePaths->Target));
51 static void extract(LPCWSTR cabfile, LPWSTR destdir)
53 if (!SetupIterateCabinetW(cabfile, 0, ExtCabCallback, destdir))
54 WINE_ERR("Could not extract cab file %s\n", wine_dbgstr_w(cabfile));
57 int PASCAL wWinMain(HINSTANCE hInstance, HINSTANCE prev, LPWSTR cmdline, int show)
64 WCHAR backslash[] = {'\\',0};
65 LPCWSTR cabfile = NULL;
68 argv = CommandLineToArgvW(cmdline, &argc);
72 WINE_ERR("Bad command line arguments\n");
77 for(i = 0; i < argc; i++)
80 if ((argv[i][0] != '/') && !cabfile)
85 /* Get parameters for commands */
86 check = toupperW( argv[i][1] );
90 WINE_FIXME("/A not implemented\n");
93 WINE_FIXME("/Y not implemented\n");
96 if ((i + 1) >= argc) return 0;
97 if (!GetFullPathNameW(argv[++i], MAX_PATH, path, NULL))
102 if ((i + 2) >= argc) return 0;
105 if (!GetFullPathNameW(argv[++i], MAX_PATH, path, NULL))
122 GetCurrentDirectoryW(MAX_PATH, path);
124 lstrcatW(path, backslash);
126 /* Execute the specified command */
131 WINE_FIXME("/C not implemented\n");
134 /* Extract CAB archive */
135 extract(cabfile, path);
139 /* Display CAB archive */
140 WINE_FIXME("/D not implemented\n");