[123] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: extract.c 1306 2008-11-30 19:23:56Z gyoung $
|
---|
| 5 |
|
---|
| 6 | Copyright (c) 1993-98 M. Kimes
|
---|
[574] | 7 | Copyright (c) 2004, 2007 Steven H. Levine
|
---|
[123] | 8 |
|
---|
[186] | 9 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 10 | 05 Jun 05 SHL Use QWL_USER
|
---|
[350] | 11 | 17 Jul 06 SHL Use Runtime_Error
|
---|
[549] | 12 | 20 Dec 06 GKY Added checkbox to make default extract with directories
|
---|
[574] | 13 | 22 Mar 07 GKY Use QWL_USER
|
---|
[618] | 14 | 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods
|
---|
[793] | 15 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[1104] | 16 | 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory
|
---|
[1300] | 17 | 29 Nov 08 GKY Add the option of creating a subdirectory from the arcname
|
---|
| 18 | for the extract path.
|
---|
[123] | 19 |
|
---|
| 20 | ***********************************************************************/
|
---|
| 21 |
|
---|
[907] | 22 | #include <string.h>
|
---|
| 23 | #include <ctype.h>
|
---|
| 24 |
|
---|
[2] | 25 | #define INCL_WIN
|
---|
| 26 | #define INCL_DOS
|
---|
[907] | 27 | #define INCL_LONGLONG // dircnrs.h
|
---|
[2] | 28 |
|
---|
[1179] | 29 | #include "fm3dll.h"
|
---|
[1223] | 30 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
[1207] | 31 | #include "init.h" // Data declaration(s)
|
---|
| 32 | #include "arccnrs.h" // Data declaration(s)
|
---|
| 33 | #include "notebook.h" // Data declaration(s)
|
---|
| 34 | #include "mainwnd.h" // Data declaration(s)
|
---|
[2] | 35 | #include "fm3dlg.h"
|
---|
| 36 | #include "fm3str.h"
|
---|
[907] | 37 | #include "errutil.h" // Dos_Error...
|
---|
| 38 | #include "strutil.h" // GetPString
|
---|
[1157] | 39 | #include "cmdline.h" // CmdLineDlgProc
|
---|
| 40 | #include "extract.h"
|
---|
| 41 | #include "walkem.h" // WalkExtractDlgProc
|
---|
[1179] | 42 | #include "droplist.h" // AcceptOneDrop, DropHelp, GetOneDrop
|
---|
| 43 | #include "misc.h" // DrawTargetEmphasis
|
---|
| 44 | #include "chklist.h" // PosOverOkay
|
---|
| 45 | #include "mkdir.h" // SetDir
|
---|
| 46 | #include "valid.h" // MakeValidDir
|
---|
| 47 | #include "systemf.h" // runemf2
|
---|
| 48 | #include "dirs.h" // save_dir2
|
---|
| 49 | #include "strips.h" // bstrip
|
---|
[2] | 50 |
|
---|
| 51 | #pragma data_seg(DATA1)
|
---|
[350] | 52 |
|
---|
| 53 | static PSZ pszSrcFile = __FILE__;
|
---|
[2] | 54 |
|
---|
[551] | 55 | MRESULT EXPENTRY ExtractTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[350] | 56 | {
|
---|
[574] | 57 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 58 | static BOOL emphasized = FALSE;
|
---|
[2] | 59 |
|
---|
[551] | 60 | switch (msg) {
|
---|
| 61 | case DM_DRAGOVER:
|
---|
| 62 | if (!emphasized) {
|
---|
| 63 | emphasized = TRUE;
|
---|
| 64 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
| 65 | }
|
---|
[618] | 66 | if (AcceptOneDrop(hwnd, mp1, mp2))
|
---|
[551] | 67 | return MRFROM2SHORT(DOR_DROP, DO_MOVE);
|
---|
| 68 | return MRFROM2SHORT(DOR_NEVERDROP, 0);
|
---|
[2] | 69 |
|
---|
[551] | 70 | case DM_DRAGLEAVE:
|
---|
| 71 | if (emphasized) {
|
---|
| 72 | emphasized = FALSE;
|
---|
| 73 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
| 74 | }
|
---|
| 75 | break;
|
---|
[2] | 76 |
|
---|
[551] | 77 | case DM_DROPHELP:
|
---|
| 78 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_EXTDROPHELPTEXT));
|
---|
| 79 | return 0;
|
---|
[2] | 80 |
|
---|
[551] | 81 | case DM_DROP:
|
---|
| 82 | {
|
---|
| 83 | char szFrom[CCHMAXPATH + 2];
|
---|
[2] | 84 |
|
---|
[551] | 85 | if (emphasized) {
|
---|
| 86 | emphasized = FALSE;
|
---|
| 87 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
[2] | 88 | }
|
---|
[618] | 89 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom)))
|
---|
[551] | 90 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_COMMAND,
|
---|
| 91 | MPFROM2SHORT(IDM_SWITCH, 0), MPFROMP(szFrom));
|
---|
| 92 | }
|
---|
| 93 | return 0;
|
---|
[2] | 94 | }
|
---|
[551] | 95 | return (oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
|
---|
| 96 | WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 97 | }
|
---|
| 98 |
|
---|
[551] | 99 | MRESULT EXPENTRY ExtractDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[350] | 100 | {
|
---|
[551] | 101 | EXTRDATA *arcdata = NULL;
|
---|
[1300] | 102 | ULONG size = sizeof(BOOL);
|
---|
| 103 | BOOL fFileNameExtPath;
|
---|
[2] | 104 |
|
---|
[551] | 105 | switch (msg) {
|
---|
| 106 | case WM_INITDLG:
|
---|
[574] | 107 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
---|
[551] | 108 | arcdata = (EXTRDATA *) mp2;
|
---|
| 109 | {
|
---|
[1300] | 110 | ULONG sizet;
|
---|
[551] | 111 | BOOL fRemember = FALSE;
|
---|
| 112 | BOOL fDirectory = FALSE;
|
---|
| 113 | PFNWP oldproc;
|
---|
[2] | 114 |
|
---|
[1300] | 115 | fFileNameExtPath = FALSE;
|
---|
[551] | 116 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, EXT_DIRECTORY),
|
---|
| 117 | (PFNWP) ExtractTextProc);
|
---|
| 118 | if (oldproc)
|
---|
| 119 | WinSetWindowPtr(WinWindowFromID(hwnd, EXT_DIRECTORY),
|
---|
| 120 | QWL_USER, (PVOID) oldproc);
|
---|
| 121 | PrfQueryProfileData(fmprof, FM3Str, "RememberExt",
|
---|
| 122 | (PVOID) & fRemember, &size);
|
---|
| 123 | PrfQueryProfileData(fmprof, FM3Str, "DirectoryExt",
|
---|
[1300] | 124 | (PVOID) & fDirectory, &size);
|
---|
| 125 | PrfQueryProfileData(fmprof, FM3Str, "FileNamePathExt",
|
---|
| 126 | (PVOID) & fFileNameExtPath, &size);
|
---|
[551] | 127 | WinCheckButton(hwnd, EXT_REMEMBER, fRemember);
|
---|
| 128 | WinCheckButton(hwnd, EXT_AWDIRS, fDirectory);
|
---|
[1300] | 129 | WinCheckButton(hwnd, EXT_FILENAMEEXT, fFileNameExtPath);
|
---|
[551] | 130 | WinSendDlgItemMsg(hwnd, EXT_DIRECTORY, EM_SETTEXTLIMIT,
|
---|
| 131 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 132 | WinSendDlgItemMsg(hwnd, EXT_COMMAND, EM_SETTEXTLIMIT,
|
---|
| 133 | MPFROM2SHORT(256, 0), MPVOID);
|
---|
| 134 | WinSendDlgItemMsg(hwnd, EXT_MASK, EM_SETTEXTLIMIT,
|
---|
| 135 | MPFROM2SHORT(256, 0), MPVOID);
|
---|
| 136 | WinSendDlgItemMsg(hwnd, EXT_FILENAME, EM_SETTEXTLIMIT,
|
---|
| 137 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 138 | if (arcdata->arcname && *arcdata->arcname)
|
---|
| 139 | WinSetDlgItemText(hwnd, EXT_FILENAME, arcdata->arcname);
|
---|
| 140 | else
|
---|
[1300] | 141 | WinSetDlgItemText(hwnd, EXT_FILENAME, GetPString(IDS_EXTVARIOUSTEXT));
|
---|
| 142 |
|
---|
| 143 | if (fFileNameExtPath && arcdata->arcname) {
|
---|
| 144 |
|
---|
| 145 | CHAR FileName[CCHMAXPATH];
|
---|
| 146 | PSZ p;
|
---|
| 147 |
|
---|
| 148 | strcpy(FileName, arcdata->arcname);
|
---|
| 149 | p = strrchr(FileName, '.');
|
---|
| 150 | if (p)
|
---|
| 151 | *p = 0;
|
---|
| 152 | else {
|
---|
| 153 | p = FileName + strlen(arcdata->arcname);
|
---|
| 154 | p--;
|
---|
| 155 | *p = 0;
|
---|
| 156 | }
|
---|
| 157 | strcpy(arcdata->extractdir, FileName);
|
---|
| 158 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir);
|
---|
| 159 | }
|
---|
[551] | 160 | if (fDirectory) {
|
---|
| 161 | WinSendDlgItemMsg(hwnd, EXT_WDIRS, BM_SETCHECK,
|
---|
| 162 | MPFROM2SHORT(TRUE, 0), MPVOID);
|
---|
| 163 | WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->exwdirs);
|
---|
| 164 | }
|
---|
| 165 | else {
|
---|
| 166 | WinSendDlgItemMsg(hwnd, EXT_NORMAL, BM_SETCHECK,
|
---|
| 167 | MPFROM2SHORT(TRUE, 0), MPVOID);
|
---|
| 168 | WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->extract);
|
---|
[549] | 169 |
|
---|
[551] | 170 | }
|
---|
| 171 | if (fRemember) {
|
---|
[2] | 172 |
|
---|
[551] | 173 | CHAR textdir[CCHMAXPATH];
|
---|
[2] | 174 |
|
---|
[1300] | 175 | sizet = sizeof(textdir);
|
---|
[551] | 176 | *textdir = 0;
|
---|
| 177 | PrfQueryProfileData(fmprof, FM3Str, "Ext_ExtractDir",
|
---|
| 178 | (PVOID) textdir, &size);
|
---|
| 179 | if (*textdir && !IsFile(textdir))
|
---|
| 180 | strcpy(arcdata->extractdir, textdir);
|
---|
[1300] | 181 | sizet = sizeof(textdir);
|
---|
[551] | 182 | *textdir = 0;
|
---|
| 183 | PrfQueryProfileData(fmprof, FM3Str, "Ext_Mask", (PVOID) textdir,
|
---|
| 184 | &size);
|
---|
| 185 | WinSetDlgItemText(hwnd, EXT_MASK, textdir);
|
---|
| 186 | }
|
---|
| 187 | if (*extractpath && (!fRemember || !*arcdata->extractdir)) {
|
---|
| 188 | if (arcdata->arcname && *arcdata->arcname &&
|
---|
| 189 | !strcmp(extractpath, "*")) {
|
---|
[2] | 190 |
|
---|
[551] | 191 | CHAR *p;
|
---|
[2] | 192 |
|
---|
[551] | 193 | strcpy(arcdata->extractdir, arcdata->arcname);
|
---|
| 194 | p = strrchr(arcdata->extractdir, '\\');
|
---|
| 195 | if (p) {
|
---|
| 196 | if (p < arcdata->extractdir + 3)
|
---|
| 197 | p++;
|
---|
| 198 | *p = 0;
|
---|
| 199 | }
|
---|
| 200 | }
|
---|
| 201 | else
|
---|
| 202 | strcpy(arcdata->extractdir, extractpath);
|
---|
| 203 | }
|
---|
| 204 | if (!*arcdata->extractdir) {
|
---|
| 205 | if (*lastextractpath)
|
---|
| 206 | strcpy(arcdata->extractdir, lastextractpath);
|
---|
| 207 | else if (arcdata->arcname && *arcdata->arcname) {
|
---|
[2] | 208 |
|
---|
[551] | 209 | CHAR *p;
|
---|
[2] | 210 |
|
---|
[551] | 211 | strcpy(arcdata->extractdir, arcdata->arcname);
|
---|
| 212 | p = strrchr(arcdata->extractdir, '\\');
|
---|
| 213 | if (p) {
|
---|
| 214 | if (p < arcdata->extractdir + 3)
|
---|
| 215 | p++;
|
---|
| 216 | *p = 0;
|
---|
| 217 | }
|
---|
| 218 | }
|
---|
| 219 | if (!*arcdata->extractdir)
|
---|
[1104] | 220 | strcpy(arcdata->extractdir, pFM2SaveDirectory);
|
---|
[2] | 221 | }
|
---|
[551] | 222 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir);
|
---|
| 223 | if (!arcdata->info->exwdirs)
|
---|
| 224 | WinEnableWindow(WinWindowFromID(hwnd, EXT_WDIRS), FALSE);
|
---|
| 225 | else if (fRemember) {
|
---|
[1300] | 226 | //size = sizeof(BOOL);
|
---|
[551] | 227 | fRemember = FALSE;
|
---|
| 228 | PrfQueryProfileData(fmprof, FM3Str, "Ext_WDirs",
|
---|
[1300] | 229 | (PVOID) &fRemember, &size);
|
---|
[551] | 230 | if (fRemember)
|
---|
| 231 | PostMsg(WinWindowFromID(hwnd, EXT_WDIRS), BM_CLICK, MPVOID, MPVOID);
|
---|
| 232 | }
|
---|
| 233 | }
|
---|
| 234 | *arcdata->command = 0;
|
---|
| 235 | PosOverOkay(hwnd);
|
---|
| 236 | break;
|
---|
[2] | 237 |
|
---|
[551] | 238 | case WM_ADJUSTWINDOWPOS:
|
---|
| 239 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 240 | break;
|
---|
[2] | 241 |
|
---|
[551] | 242 | case UM_SETDIR:
|
---|
| 243 | PaintRecessedWindow(WinWindowFromID(hwnd, EXT_HELP), (HPS) 0, FALSE,
|
---|
| 244 | TRUE);
|
---|
| 245 | return 0;
|
---|
[2] | 246 |
|
---|
[551] | 247 | case WM_CONTROL:
|
---|
[574] | 248 | arcdata = (EXTRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 249 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 250 | case EXT_REMEMBER:
|
---|
| 251 | {
|
---|
| 252 | BOOL fRemember = WinQueryButtonCheckstate(hwnd, EXT_REMEMBER);
|
---|
[2] | 253 |
|
---|
[551] | 254 | PrfWriteProfileData(fmprof, FM3Str, "RememberExt",
|
---|
[1300] | 255 | (PVOID) &fRemember, size);
|
---|
[551] | 256 | }
|
---|
| 257 | break;
|
---|
[2] | 258 |
|
---|
[551] | 259 | case EXT_AWDIRS:
|
---|
| 260 | {
|
---|
| 261 | BOOL fDirectory = WinQueryButtonCheckstate(hwnd, EXT_AWDIRS);
|
---|
[549] | 262 |
|
---|
[551] | 263 | PrfWriteProfileData(fmprof, FM3Str, "DirectoryExt",
|
---|
[1300] | 264 | (PVOID) &fDirectory, size);
|
---|
[549] | 265 |
|
---|
[551] | 266 | if (fDirectory) {
|
---|
| 267 | WinSendDlgItemMsg(hwnd, EXT_WDIRS, BM_SETCHECK,
|
---|
| 268 | MPFROM2SHORT(TRUE, 0), MPVOID);
|
---|
| 269 | WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->exwdirs);
|
---|
| 270 | }
|
---|
| 271 | else {
|
---|
| 272 | WinSendDlgItemMsg(hwnd, EXT_NORMAL, BM_SETCHECK,
|
---|
| 273 | MPFROM2SHORT(TRUE, 0), MPVOID);
|
---|
| 274 | WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->extract);
|
---|
| 275 | }
|
---|
| 276 | }
|
---|
| 277 | break;
|
---|
[549] | 278 |
|
---|
[1300] | 279 | case EXT_FILENAMEEXT:
|
---|
| 280 | {
|
---|
| 281 | BOOL fFileNameExtPath = WinQueryButtonCheckstate(hwnd, EXT_FILENAMEEXT);
|
---|
| 282 |
|
---|
| 283 | PrfWriteProfileData(fmprof, FM3Str, "FileNamePathExt",
|
---|
| 284 | (PVOID) &fFileNameExtPath, size);
|
---|
| 285 | if (fFileNameExtPath && arcdata->arcname) {
|
---|
| 286 | CHAR FileName[CCHMAXPATH];
|
---|
| 287 | PSZ p;
|
---|
| 288 |
|
---|
| 289 | strcpy(FileName, arcdata->arcname);
|
---|
| 290 | p = strrchr(FileName, '.');
|
---|
| 291 | if (p)
|
---|
| 292 | *p = 0;
|
---|
| 293 | else {
|
---|
| 294 | p = FileName + strlen(arcdata->arcname);
|
---|
| 295 | p--;
|
---|
| 296 | *p = 0;
|
---|
| 297 | }
|
---|
| 298 | strcpy(arcdata->extractdir, FileName);
|
---|
| 299 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir);
|
---|
| 300 | }
|
---|
| 301 | else {
|
---|
| 302 | *arcdata->extractdir = 0;
|
---|
| 303 | if (*extractpath) {
|
---|
| 304 | if (arcdata->arcname && *arcdata->arcname &&
|
---|
| 305 | !strcmp(extractpath, "*")) {
|
---|
| 306 |
|
---|
| 307 | CHAR *p;
|
---|
| 308 |
|
---|
| 309 | strcpy(arcdata->extractdir, arcdata->arcname);
|
---|
| 310 | p = strrchr(arcdata->extractdir, '\\');
|
---|
| 311 | if (p) {
|
---|
| 312 | if (p < arcdata->extractdir + 3)
|
---|
| 313 | p++;
|
---|
| 314 | *p = 0;
|
---|
| 315 | }
|
---|
| 316 | }
|
---|
| 317 | else
|
---|
| 318 | strcpy(arcdata->extractdir, extractpath);
|
---|
| 319 | }
|
---|
| 320 | if (!*arcdata->extractdir) {
|
---|
[1306] | 321 | if (arcdata->arcname && *arcdata->arcname) {
|
---|
[1300] | 322 |
|
---|
| 323 | CHAR *p;
|
---|
| 324 |
|
---|
| 325 | strcpy(arcdata->extractdir, arcdata->arcname);
|
---|
| 326 | p = strrchr(arcdata->extractdir, '\\');
|
---|
| 327 | if (p) {
|
---|
| 328 | if (p < arcdata->extractdir + 3)
|
---|
| 329 | p++;
|
---|
| 330 | *p = 0;
|
---|
| 331 | }
|
---|
| 332 | }
|
---|
| 333 | if (!*arcdata->extractdir)
|
---|
| 334 | strcpy(arcdata->extractdir, pFM2SaveDirectory);
|
---|
| 335 | }
|
---|
| 336 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir);
|
---|
| 337 | }
|
---|
| 338 | }
|
---|
| 339 | break;
|
---|
| 340 |
|
---|
[551] | 341 | case EXT_FILENAME:
|
---|
| 342 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
| 343 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT));
|
---|
| 344 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
| 345 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCARCNAMEHELPTEXT));
|
---|
| 346 | break;
|
---|
[2] | 347 |
|
---|
[551] | 348 | case EXT_DIRECTORY:
|
---|
| 349 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
| 350 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT));
|
---|
| 351 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
| 352 | WinSetDlgItemText(hwnd, EXT_HELP,
|
---|
| 353 | GetPString(IDS_EXTEXTRACTDIRHELPTEXT));
|
---|
| 354 | break;
|
---|
[2] | 355 |
|
---|
[551] | 356 | case EXT_COMMAND:
|
---|
| 357 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
| 358 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT));
|
---|
| 359 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
| 360 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCCMDHELPTEXT));
|
---|
| 361 | break;
|
---|
[2] | 362 |
|
---|
[551] | 363 | case EXT_MASK:
|
---|
| 364 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
| 365 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT));
|
---|
| 366 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
| 367 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCMASKHELPTEXT));
|
---|
| 368 | break;
|
---|
[2] | 369 |
|
---|
[551] | 370 | case EXT_NORMAL:
|
---|
| 371 | if ((BOOL) WinSendDlgItemMsg(hwnd, EXT_NORMAL, BM_QUERYCHECK,
|
---|
| 372 | MPVOID, MPVOID))
|
---|
| 373 | WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->extract);
|
---|
| 374 | break;
|
---|
[2] | 375 |
|
---|
[551] | 376 | case EXT_WDIRS:
|
---|
| 377 | if (arcdata->info->exwdirs) {
|
---|
| 378 | if ((BOOL) WinSendDlgItemMsg(hwnd, EXT_WDIRS, BM_QUERYCHECK,
|
---|
| 379 | MPVOID, MPVOID))
|
---|
| 380 | WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->exwdirs);
|
---|
[2] | 381 | }
|
---|
[551] | 382 | break;
|
---|
| 383 | }
|
---|
| 384 | return 0;
|
---|
[2] | 385 |
|
---|
[551] | 386 | case WM_COMMAND:
|
---|
[574] | 387 | arcdata = (EXTRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 388 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 389 | case IDM_SWITCH:
|
---|
| 390 | if (mp2) {
|
---|
[2] | 391 |
|
---|
[551] | 392 | CHAR tdir[CCHMAXPATH];
|
---|
[2] | 393 |
|
---|
[551] | 394 | strcpy(tdir, (CHAR *) mp2);
|
---|
| 395 | MakeValidDir(tdir);
|
---|
| 396 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, tdir);
|
---|
| 397 | }
|
---|
| 398 | break;
|
---|
[2] | 399 |
|
---|
[551] | 400 | case DID_CANCEL:
|
---|
| 401 | arcdata->ret = 0;
|
---|
| 402 | WinDismissDlg(hwnd, 0);
|
---|
| 403 | break;
|
---|
| 404 | case DID_OK:
|
---|
| 405 | {
|
---|
| 406 | CHAR s[CCHMAXPATH + 1];
|
---|
| 407 | BOOL fRemember;
|
---|
[2] | 408 |
|
---|
[551] | 409 | fRemember = WinQueryButtonCheckstate(hwnd, EXT_REMEMBER);
|
---|
| 410 | *s = 0;
|
---|
| 411 | WinQueryDlgItemText(hwnd, EXT_DIRECTORY, CCHMAXPATH, s);
|
---|
| 412 | bstrip(s);
|
---|
| 413 | if (*s) {
|
---|
| 414 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
[1300] | 415 | QW_OWNER), hwnd, s, fFileNameExtPath ? 1:0)) {
|
---|
[551] | 416 | strcpy(arcdata->extractdir, s);
|
---|
| 417 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, s);
|
---|
| 418 | if ((!isalpha(*s) || s[1] != ':') && *s != '.')
|
---|
| 419 | saymsg(MB_ENTER, hwnd,
|
---|
| 420 | GetPString(IDS_WARNINGTEXT),
|
---|
| 421 | GetPString(IDS_SPECIFYDRIVETEXT));
|
---|
| 422 | }
|
---|
| 423 | else
|
---|
| 424 | break;
|
---|
| 425 | strcpy(lastextractpath, s);
|
---|
| 426 | if (fRemember) {
|
---|
| 427 | PrfWriteProfileString(fmprof, FM3Str, "Ext_ExtractDir", s);
|
---|
| 428 | fRemember = WinQueryButtonCheckstate(hwnd, EXT_WDIRS);
|
---|
| 429 | PrfWriteProfileData(fmprof, FM3Str, "Ext_WDirs",
|
---|
[1300] | 430 | (PVOID) &fRemember, size);
|
---|
[551] | 431 | fRemember = TRUE;
|
---|
| 432 | }
|
---|
| 433 | *s = 0;
|
---|
| 434 | WinQueryDlgItemText(hwnd, EXT_COMMAND, 256, s);
|
---|
| 435 | if (*s) {
|
---|
| 436 | strcpy(arcdata->command, s);
|
---|
| 437 | *s = 0;
|
---|
| 438 | WinQueryDlgItemText(hwnd, EXT_MASK, 256, s);
|
---|
| 439 | *arcdata->masks = 0;
|
---|
| 440 | strcpy(arcdata->masks, s);
|
---|
| 441 | if (fRemember)
|
---|
| 442 | PrfWriteProfileString(fmprof, FM3Str, "Ext_Mask", s);
|
---|
| 443 | arcdata->ret = 1;
|
---|
| 444 | WinDismissDlg(hwnd, 1);
|
---|
| 445 | break;
|
---|
| 446 | }
|
---|
| 447 | }
|
---|
| 448 | }
|
---|
| 449 | DosBeep(50, 100); // Complain a refuse to quit
|
---|
| 450 | break;
|
---|
[2] | 451 |
|
---|
[551] | 452 | case IDM_HELP:
|
---|
| 453 | if (hwndHelp)
|
---|
| 454 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
| 455 | MPFROM2SHORT(HELP_EXTRACT, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
| 456 | break;
|
---|
[2] | 457 |
|
---|
[551] | 458 | case EXT_WALK:
|
---|
| 459 | {
|
---|
| 460 | CHAR temp[CCHMAXPATH + 1];
|
---|
[2] | 461 |
|
---|
[551] | 462 | strcpy(temp, arcdata->extractdir);
|
---|
| 463 | if (WinDlgBox(HWND_DESKTOP, WinQueryWindow(WinQueryWindow(hwnd,
|
---|
| 464 | QW_PARENT),
|
---|
| 465 | QW_OWNER),
|
---|
| 466 | WalkExtractDlgProc, FM3ModHandle, WALK_FRAME,
|
---|
| 467 | (PVOID) temp)) {
|
---|
| 468 | if (*temp && stricmp(temp, arcdata->extractdir)) {
|
---|
| 469 | strcpy(arcdata->extractdir, temp);
|
---|
| 470 | }
|
---|
| 471 | }
|
---|
| 472 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir);
|
---|
| 473 | }
|
---|
| 474 | break;
|
---|
[2] | 475 |
|
---|
[551] | 476 | case EXT_SEE:
|
---|
| 477 | {
|
---|
| 478 | CHAR s[1001], *p;
|
---|
| 479 | EXECARGS ex;
|
---|
[2] | 480 |
|
---|
[551] | 481 | WinQueryDlgItemText(hwnd, EXT_COMMAND, 256, s);
|
---|
| 482 | lstrip(s);
|
---|
| 483 | if (!*s)
|
---|
| 484 | Runtime_Error(pszSrcFile, __LINE__, "no command");
|
---|
| 485 | else {
|
---|
| 486 | p = strchr(s, ' ');
|
---|
| 487 | if (p)
|
---|
| 488 | *p = 0; // Drop options
|
---|
| 489 | memset(&ex, 0, sizeof(EXECARGS));
|
---|
| 490 | ex.commandline = s;
|
---|
| 491 | ex.flags = WINDOWED | SEPARATEKEEP | MAXIMIZED;
|
---|
| 492 | *ex.path = 0;
|
---|
| 493 | *ex.environment = 0;
|
---|
| 494 | if (WinDlgBox(HWND_DESKTOP,
|
---|
| 495 | hwnd,
|
---|
| 496 | CmdLineDlgProc,
|
---|
| 497 | FM3ModHandle, EXEC_FRAME, MPFROMP(&ex)) && *s) {
|
---|
| 498 | runemf2(ex.flags,
|
---|
[888] | 499 | hwnd, pszSrcFile, __LINE__,
|
---|
[551] | 500 | NULL, (*ex.environment) ? ex.environment : NULL, "%s", s);
|
---|
| 501 | }
|
---|
| 502 | }
|
---|
[2] | 503 | }
|
---|
[551] | 504 | break;
|
---|
| 505 | }
|
---|
| 506 | return 0;
|
---|
[2] | 507 |
|
---|
[551] | 508 | case WM_CLOSE:
|
---|
| 509 | break;
|
---|
[2] | 510 | }
|
---|
[551] | 511 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 512 | }
|
---|
[793] | 513 |
|
---|
| 514 | #pragma alloc_text(FMEXTRACT,ExtractTextProc,ExtractDlgProc)
|
---|