[27] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: arccnrs.c 551 2007-02-28 01:33:51Z gyoung $
|
---|
| 5 |
|
---|
[123] | 6 | Archive containers
|
---|
| 7 |
|
---|
[28] | 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[300] | 9 | Copyright (c) 2001, 2006 Steven H. Levine
|
---|
[27] | 10 |
|
---|
[130] | 11 | 11 Jun 02 SHL Ensure archive name not garbage
|
---|
| 12 | 22 May 03 SHL ArcObjWndProc: fix UM_RESCAN now that we understand it
|
---|
| 13 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 14 | 23 May 05 SHL Use QWL_USER
|
---|
[156] | 15 | 25 May 05 SHL Rename comnam to szCommonName and fix typo
|
---|
| 16 | 25 May 05 SHL Use ULONGLONG and CommaFmtULL
|
---|
[212] | 17 | 05 Jun 05 SHL Drop obsolete, localize
|
---|
| 18 | 05 Jun 05 SHL Correct last sort logic
|
---|
| 19 | 05 Jun 05 SHL Use QWL_USER
|
---|
[229] | 20 | 22 Jun 05 SHL ArcSort: correct typo in last sort fix
|
---|
[249] | 21 | 13 Aug 05 SHL FillArcCnr: optimize
|
---|
[300] | 22 | 08 Dec 05 SHL FillArcCnr: allow list start and end markers to be empty (i.e. tar)
|
---|
| 23 | 08 Dec 05 SHL ArcCnrWndProc: suppress IDM_EXTRACT if no simple extract (i.e. tar)
|
---|
| 24 | 30 Dec 05 SHL ArcCnrWndProc: correct date/time column display setup
|
---|
| 25 | 29 May 06 SHL Comments
|
---|
[358] | 26 | 14 Jul 06 SHL Use Runtime_Error
|
---|
[367] | 27 | 26 Jul 06 SHL Correct SelectAll usage
|
---|
[406] | 28 | 29 Jul 06 SHL Use xfgets_bstripcr
|
---|
[423] | 29 | 31 Jul 06 SHL Lower priority for archives with more than 1000 entries
|
---|
[426] | 30 | 02 Aug 06 SHL Add logic to stop processing large archives
|
---|
[460] | 31 | 23 Aug 06 SHL Integrate John Small's switch list title logic
|
---|
[531] | 32 | 03 Nov 06 SHL Renames
|
---|
[27] | 33 |
|
---|
| 34 | ***********************************************************************/
|
---|
| 35 |
|
---|
[2] | 36 | #define INCL_DOS
|
---|
| 37 | #define INCL_DOSERRORS
|
---|
| 38 | #define INCL_WIN
|
---|
| 39 | #define INCL_GPI
|
---|
[156] | 40 | #define INCL_LONGLONG
|
---|
| 41 | #include <os2.h>
|
---|
[2] | 42 |
|
---|
| 43 | #include <stdarg.h>
|
---|
| 44 | #include <stdio.h>
|
---|
| 45 | #include <stdlib.h>
|
---|
| 46 | #include <string.h>
|
---|
| 47 | #include <ctype.h>
|
---|
| 48 | #include <time.h>
|
---|
| 49 | #include <direct.h>
|
---|
| 50 | #include <share.h>
|
---|
| 51 | #include <limits.h>
|
---|
[156] | 52 |
|
---|
[2] | 53 | #include "fm3dll.h"
|
---|
| 54 | #include "fm3dlg.h"
|
---|
| 55 | #include "fm3str.h"
|
---|
| 56 | #include "mle.h"
|
---|
| 57 |
|
---|
| 58 | #pragma data_seg(DATA1)
|
---|
[358] | 59 |
|
---|
| 60 | static INT DefArcSortFlags;
|
---|
| 61 | static PSZ pszSrcFile = __FILE__;
|
---|
| 62 |
|
---|
[2] | 63 | #pragma alloc_text(ARCCNRS,ArcCnrWndProc,ArcObjWndProc,ArcClientWndProc)
|
---|
| 64 | #pragma alloc_text(ARCCNRS,ArcTextProc,FillArcCnr,ArcFilter)
|
---|
| 65 | #pragma alloc_text(ARCCNRS,ArcSort,ArcFrameWndProc,IsArcThere,ArcErrProc)
|
---|
| 66 | #pragma alloc_text(STARTUP,StartArcCnr)
|
---|
| 67 |
|
---|
[551] | 68 | static MRESULT EXPENTRY ArcErrProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 69 | MPARAM mp2)
|
---|
[172] | 70 | {
|
---|
[2] | 71 | ARCDUMP *ad;
|
---|
| 72 |
|
---|
[551] | 73 | switch (msg) {
|
---|
| 74 | case WM_INITDLG:
|
---|
| 75 | if (!mp2)
|
---|
| 76 | WinDismissDlg(hwnd, 0);
|
---|
| 77 | else {
|
---|
| 78 | ad = (ARCDUMP *) mp2;
|
---|
| 79 | WinSetWindowPtr(hwnd, QWL_USER, ad);
|
---|
| 80 | if (ad->errmsg)
|
---|
| 81 | WinSetDlgItemText(hwnd, ARCERR_TEXT, ad->errmsg);
|
---|
| 82 | if (!ad->info->test)
|
---|
| 83 | WinEnableWindow(WinWindowFromID(hwnd, ARCERR_TEST), FALSE);
|
---|
| 84 | if (ad->listname) {
|
---|
| 85 | MLEsetlimit(WinWindowFromID(hwnd, ARCERR_MLE), -1L);
|
---|
| 86 | MLEsetformat(WinWindowFromID(hwnd, ARCERR_MLE), MLFIE_NOTRANS);
|
---|
| 87 | MLEsetcurpos(WinWindowFromID(hwnd, ARCERR_MLE),
|
---|
| 88 | MLEgetlen(WinWindowFromID(hwnd, ARCERR_MLE)));
|
---|
| 89 | MLEinsert(WinWindowFromID(hwnd, ARCERR_MLE),
|
---|
| 90 | GetPString(IDS_ARCHIVERREPORTTEXT));
|
---|
| 91 | MLEinsertfile(WinWindowFromID(hwnd, ARCERR_MLE), ad->listname);
|
---|
[2] | 92 | }
|
---|
[551] | 93 | }
|
---|
| 94 | break;
|
---|
| 95 |
|
---|
| 96 | case WM_COMMAND:
|
---|
| 97 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 98 | case DID_CANCEL:
|
---|
| 99 | WinDismissDlg(hwnd, 0);
|
---|
[2] | 100 | break;
|
---|
| 101 |
|
---|
[551] | 102 | case IDM_HELP:
|
---|
| 103 | if (hwndHelp) {
|
---|
| 104 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
| 105 | MPFROM2SHORT(HELP_ARCERR, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
| 106 | }
|
---|
| 107 | break;
|
---|
[2] | 108 |
|
---|
[551] | 109 | case DID_OK:
|
---|
| 110 | ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 111 | WinDlgBox(HWND_DESKTOP, hwnd, ArcReviewDlgProc, FM3ModHandle,
|
---|
| 112 | AD_FRAME, MPFROMP(ad));
|
---|
| 113 | WinDismissDlg(hwnd, 0);
|
---|
| 114 | break;
|
---|
[2] | 115 |
|
---|
[551] | 116 | case ARCERR_VIEW:
|
---|
| 117 | ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 118 | {
|
---|
| 119 | CHAR *list[2];
|
---|
[2] | 120 |
|
---|
[551] | 121 | list[0] = ad->arcname;
|
---|
| 122 | list[1] = NULL;
|
---|
| 123 | if (TestBinary(ad->arcname)) {
|
---|
| 124 | if (*binview)
|
---|
| 125 | ExecOnList((HWND) 0, binview, WINDOWED | SEPARATE, NULL, list,
|
---|
| 126 | NULL);
|
---|
| 127 | else
|
---|
| 128 | StartMLEEditor(HWND_DESKTOP, 16 + 4 + 1, ad->arcname, hwnd);
|
---|
| 129 | }
|
---|
| 130 | else {
|
---|
| 131 | if (*viewer) {
|
---|
| 132 | ExecOnList((HWND) 0, viewer, WINDOWED | SEPARATE |
|
---|
| 133 | ((fViewChild) ? CHILD : 0), NULL, list, NULL);
|
---|
| 134 | }
|
---|
| 135 | else
|
---|
| 136 | StartMLEEditor(HWND_DESKTOP, 8 + 4 + 1, ad->arcname, hwnd);
|
---|
| 137 | }
|
---|
| 138 | }
|
---|
| 139 | break;
|
---|
[2] | 140 |
|
---|
[551] | 141 | case ARCERR_TEST:
|
---|
| 142 | ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 143 | runemf2(SEPARATEKEEP | WINDOWED | MAXIMIZED,
|
---|
| 144 | hwnd, NULL, NULL, "%s %s%s%s", ad->info->test,
|
---|
| 145 | ((needs_quoting(ad->arcname)) ? "\"" : NullStr),
|
---|
| 146 | ad->arcname, ((needs_quoting(ad->arcname)) ? "\"" : NullStr));
|
---|
| 147 | break;
|
---|
| 148 | }
|
---|
| 149 | return 0;
|
---|
[2] | 150 | }
|
---|
[551] | 151 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 152 | }
|
---|
| 153 |
|
---|
[551] | 154 | static SHORT APIENTRY ArcSort(PMINIRECORDCORE pmrc1, PMINIRECORDCORE pmrc2,
|
---|
| 155 | PVOID pStorage)
|
---|
[172] | 156 | {
|
---|
[551] | 157 | PARCITEM pai1 = (PARCITEM) pmrc1;
|
---|
| 158 | PARCITEM pai2 = (PARCITEM) pmrc2;
|
---|
| 159 | DIRCNRDATA *pdcd = (DIRCNRDATA *) pStorage;
|
---|
| 160 | SHORT ret = 0;
|
---|
| 161 | CHAR *pext, *ppext;
|
---|
| 162 | INT sortFlags;
|
---|
[2] | 163 |
|
---|
[423] | 164 | if (!pdcd) {
|
---|
[212] | 165 | HWND hwndCnr = pai1->hwndCnr;
|
---|
[551] | 166 |
|
---|
| 167 | pdcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
|
---|
[358] | 168 | if (!pdcd) {
|
---|
[377] | 169 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
[212] | 170 | return ret;
|
---|
| 171 | }
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | sortFlags = pdcd->sortFlags; // Optimize
|
---|
| 175 |
|
---|
[423] | 176 | if (sortFlags) {
|
---|
[551] | 177 | switch (sortFlags & (~SORT_REVERSE)) {
|
---|
| 178 | case SORT_FIRSTEXTENSION:
|
---|
| 179 | pext = strchr(pai1->szFileName, '.');
|
---|
| 180 | ppext = strchr(pai2->szFileName, '.');
|
---|
| 181 | if (!pext)
|
---|
| 182 | pext = NullStr;
|
---|
| 183 | if (!ppext)
|
---|
| 184 | ppext = NullStr;
|
---|
| 185 | ret = stricmp(pext, ppext);
|
---|
| 186 | break;
|
---|
[2] | 187 |
|
---|
[551] | 188 | case SORT_LASTEXTENSION:
|
---|
| 189 | pext = strrchr(pai1->szFileName, '.');
|
---|
| 190 | ppext = strrchr(pai2->szFileName, '.');
|
---|
| 191 | if (!pext)
|
---|
| 192 | pext = NullStr;
|
---|
| 193 | if (!ppext)
|
---|
| 194 | ppext = NullStr;
|
---|
| 195 | ret = stricmp(pext, ppext);
|
---|
| 196 | break;
|
---|
[2] | 197 |
|
---|
[551] | 198 | case SORT_LWDATE:
|
---|
| 199 | ret = (pai1->date.year < pai2->date.year) ? 1 :
|
---|
| 200 | (pai1->date.year > pai2->date.year) ? -1 :
|
---|
| 201 | (pai1->date.month < pai2->date.month) ? 1 :
|
---|
| 202 | (pai1->date.month > pai2->date.month) ? -1 :
|
---|
| 203 | (pai1->date.day < pai2->date.day) ? 1 :
|
---|
| 204 | (pai1->date.day > pai2->date.day) ? -1 :
|
---|
| 205 | (pai1->time.hours < pai2->time.hours) ? 1 :
|
---|
| 206 | (pai1->time.hours > pai2->time.hours) ? -1 :
|
---|
| 207 | (pai1->time.minutes < pai2->time.minutes) ? 1 :
|
---|
| 208 | (pai1->time.minutes > pai2->time.minutes) ? -1 :
|
---|
| 209 | (pai1->time.seconds < pai2->time.seconds) ? 1 :
|
---|
| 210 | (pai1->time.seconds > pai2->time.seconds) ? -1 : 0;
|
---|
| 211 | break;
|
---|
[2] | 212 |
|
---|
[551] | 213 | case SORT_SIZE:
|
---|
| 214 | ret =
|
---|
| 215 | (pai1->cbFile < pai2->cbFile) ? 1 : (pai1->cbFile ==
|
---|
| 216 | pai2->cbFile) ? 0 : -1;
|
---|
| 217 | if (!ret)
|
---|
| 218 | ret =
|
---|
| 219 | (pai1->cbComp < pai2->cbComp) ? 1 : (pai1->cbComp ==
|
---|
| 220 | pai2->cbComp) ? 0 : -1;
|
---|
| 221 | break;
|
---|
[2] | 222 |
|
---|
[551] | 223 | case SORT_EASIZE:
|
---|
| 224 | ret =
|
---|
| 225 | (pai1->cbComp < pai2->cbComp) ? 1 : (pai1->cbComp ==
|
---|
| 226 | pai2->cbComp) ? 0 : -1;
|
---|
| 227 | if (!ret)
|
---|
| 228 | ret =
|
---|
| 229 | (pai1->cbFile < pai2->cbFile) ? 1 : (pai1->cbFile ==
|
---|
| 230 | pai2->cbFile) ? 0 : -1;
|
---|
| 231 | break;
|
---|
[2] | 232 | }
|
---|
[423] | 233 | if (!ret)
|
---|
[551] | 234 | ret = (SHORT) stricmp(pai1->szFileName, pai2->szFileName);
|
---|
[423] | 235 | if (ret && (sortFlags & SORT_REVERSE))
|
---|
[2] | 236 | ret = (ret > 0) ? -1 : 1;
|
---|
| 237 | return ret;
|
---|
| 238 | }
|
---|
[551] | 239 | return (SHORT) stricmp(pai1->szFileName, pai2->szFileName);
|
---|
[2] | 240 | }
|
---|
| 241 |
|
---|
[551] | 242 | static INT APIENTRY ArcFilter(PMINIRECORDCORE rmini, PVOID arg)
|
---|
[172] | 243 | {
|
---|
[551] | 244 | DIRCNRDATA *dcd = (DIRCNRDATA *) arg;
|
---|
| 245 | PARCITEM r;
|
---|
| 246 | register INT x;
|
---|
| 247 | INT ret = FALSE;
|
---|
[2] | 248 |
|
---|
[423] | 249 | if (dcd && *dcd->mask.szMask) {
|
---|
[551] | 250 | r = (PARCITEM) rmini;
|
---|
[423] | 251 | if (dcd->mask.pszMasks[1]) {
|
---|
[551] | 252 | for (x = 0; dcd->mask.pszMasks[x]; x++) {
|
---|
| 253 | if (*dcd->mask.pszMasks[x]) {
|
---|
| 254 | if (*dcd->mask.pszMasks[x] != '/') {
|
---|
| 255 | if (wildcard(r->szFileName, dcd->mask.pszMasks[x], FALSE))
|
---|
| 256 | ret = TRUE;
|
---|
| 257 | }
|
---|
| 258 | else {
|
---|
| 259 | if (wildcard(r->szFileName, dcd->mask.pszMasks[x] + 1, FALSE)) {
|
---|
| 260 | ret = FALSE;
|
---|
| 261 | break;
|
---|
| 262 | }
|
---|
| 263 | }
|
---|
| 264 | }
|
---|
[2] | 265 | }
|
---|
| 266 | }
|
---|
| 267 | else {
|
---|
[551] | 268 | if (wildcard(r->szFileName, dcd->mask.szMask, FALSE))
|
---|
| 269 | ret = TRUE;
|
---|
[2] | 270 | }
|
---|
| 271 | }
|
---|
| 272 | else
|
---|
| 273 | ret = TRUE;
|
---|
| 274 | return ret;
|
---|
| 275 | }
|
---|
| 276 |
|
---|
[551] | 277 | static MRESULT EXPENTRY ArcFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 278 | MPARAM mp2)
|
---|
[172] | 279 | {
|
---|
[551] | 280 | return CommonFrameWndProc(ARC_CNR, hwnd, msg, mp1, mp2);
|
---|
[2] | 281 | }
|
---|
| 282 |
|
---|
[551] | 283 | static BOOL IsArcThere(HWND hwnd, CHAR * arcname)
|
---|
[172] | 284 | {
|
---|
[423] | 285 | if (arcname) {
|
---|
| 286 | if (IsFile(arcname) != 1) {
|
---|
[551] | 287 | saymsg(MB_CANCEL, hwnd,
|
---|
| 288 | GetPString(IDS_SAYWHATTEXT),
|
---|
| 289 | GetPString(IDS_ARCNOTTHERETEXT), arcname);
|
---|
[2] | 290 | return FALSE;
|
---|
| 291 | }
|
---|
| 292 | return TRUE;
|
---|
| 293 | }
|
---|
| 294 | return FALSE;
|
---|
| 295 | }
|
---|
| 296 |
|
---|
[423] | 297 | //== FillArcCnr() generate archive content list and fill container window ==
|
---|
| 298 |
|
---|
[551] | 299 | static INT FillArcCnr(HWND hwndCnr, CHAR * arcname, ARC_TYPE ** arcinfo,
|
---|
| 300 | ULONGLONG * pullTotalBytes, volatile PCHAR pStopFlag)
|
---|
[44] | 301 | {
|
---|
[551] | 302 | FILE *fp;
|
---|
| 303 | HFILE oldstdout;
|
---|
| 304 | HFILE newstdout;
|
---|
| 305 | CHAR s[CCHMAXPATH * 2], lonename[CCHMAXPATH + 2],
|
---|
| 306 | *nsize, *osize, *fdate, *fname, *p, *pp, arctemp[33];
|
---|
| 307 | BOOL gotstart;
|
---|
| 308 | BOOL gotend;
|
---|
| 309 | BOOL wasquote;
|
---|
| 310 | BOOL nomove = FALSE; // fixme to be gone?
|
---|
| 311 | INT highest = 0, x, counter = 0, numarcfiles = 0;
|
---|
| 312 | PARCITEM lastpai;
|
---|
| 313 | ARC_TYPE *info;
|
---|
| 314 | ARC_TYPE *tinfo;
|
---|
| 315 | ULONG apptype;
|
---|
| 316 | APIRET rc;
|
---|
[2] | 317 |
|
---|
[423] | 318 | if (!arcname || !arcinfo)
|
---|
[2] | 319 | return 0;
|
---|
[300] | 320 |
|
---|
[2] | 321 | info = *arcinfo;
|
---|
[423] | 322 | if (!info)
|
---|
[551] | 323 | info = find_type(arcname, NULL);
|
---|
| 324 | for (x = 0; x < 99; x++) {
|
---|
| 325 | sprintf(arctemp, "%s.%03x", ArcTempRoot, (clock() & 4095L));
|
---|
[423] | 326 | if (IsFile(arctemp) == 1)
|
---|
| 327 | DosSleep(rand() % 100);
|
---|
| 328 | else
|
---|
| 329 | break;
|
---|
| 330 | }
|
---|
[300] | 331 |
|
---|
[2] | 332 | ReTry:
|
---|
| 333 |
|
---|
| 334 | #ifdef DEBUG
|
---|
[27] | 335 | if (info && info->id)
|
---|
[551] | 336 | WinSetWindowText(WinQueryWindow
|
---|
| 337 | (WinQueryWindow(hwndCnr, QW_PARENT), QW_PARENT),
|
---|
| 338 | info->id);
|
---|
[2] | 339 | #endif
|
---|
| 340 |
|
---|
| 341 | tinfo = NULL;
|
---|
| 342 | numarcfiles = counter = highest = 0;
|
---|
| 343 | gotstart = gotend = FALSE;
|
---|
| 344 | lastpai = NULL;
|
---|
[156] | 345 | *pullTotalBytes = 0;
|
---|
[358] | 346 | if (!info || !info->list)
|
---|
[377] | 347 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
[358] | 348 | else {
|
---|
[2] | 349 | WinSendMsg(hwndCnr,
|
---|
[551] | 350 | CM_REMOVERECORD,
|
---|
| 351 | MPVOID,
|
---|
| 352 | MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE));
|
---|
[2] | 353 | *arcinfo = info;
|
---|
| 354 | highest = info->osizepos;
|
---|
[423] | 355 | if (info->nsizepos > highest)
|
---|
[2] | 356 | highest = info->nsizepos;
|
---|
[423] | 357 | if (info->fdpos > highest)
|
---|
[2] | 358 | highest = info->fdpos;
|
---|
[423] | 359 | if (info->fnpos > highest)
|
---|
[2] | 360 | highest = info->fnpos;
|
---|
[423] | 361 | if (highest > 50) {
|
---|
[551] | 362 | saymsg(MB_ENTER | MB_ICONEXCLAMATION, HWND_DESKTOP,
|
---|
| 363 | GetPString(IDS_SHAMETEXT), "%s", GetPString(IDS_BUNGEDUPTEXT));
|
---|
[423] | 364 | }
|
---|
| 365 | if (info->fnpos == -1)
|
---|
[2] | 366 | highest = 32767;
|
---|
[300] | 367 |
|
---|
[2] | 368 | DosError(FERR_DISABLEHARDERR);
|
---|
| 369 | DosForceDelete(arctemp);
|
---|
| 370 | DosError(FERR_DISABLEHARDERR);
|
---|
[300] | 371 |
|
---|
[551] | 372 | strcpy(s, info->list);
|
---|
| 373 | p = strchr(s, ' ');
|
---|
[423] | 374 | if (p)
|
---|
[2] | 375 | *p = 0;
|
---|
| 376 | DosError(FERR_DISABLEHARDERR);
|
---|
[551] | 377 | if (!DosQAppType(s, &apptype) &&
|
---|
| 378 | ((apptype & FAPPTYP_DOS) ||
|
---|
| 379 | (apptype & FAPPTYP_WINDOWSREAL) ||
|
---|
| 380 | (apptype & FAPPTYP_WINDOWSPROT) || (apptype & 0x1000))) {
|
---|
[2] | 381 | p = GetCmdSpec(TRUE);
|
---|
| 382 | runemf2(SEPARATE | INVISIBLE | MINIMIZED | BACKGROUND | WAIT,
|
---|
[551] | 383 | hwndCnr,
|
---|
| 384 | NULL,
|
---|
| 385 | "DOS_BACKGROUND_EXECUTION=1",
|
---|
| 386 | "%s /C %s %s%s%s > %s",
|
---|
| 387 | p,
|
---|
| 388 | info->list,
|
---|
| 389 | (needs_quoting(arcname)) ? "\"" : NullStr,
|
---|
| 390 | arcname, (needs_quoting(arcname)) ? "\"" : NullStr, arctemp);
|
---|
[2] | 391 | }
|
---|
| 392 | else {
|
---|
[551] | 393 | fp = xfopen(arctemp, "w", pszSrcFile, __LINE__);
|
---|
[423] | 394 | if (!fp)
|
---|
[551] | 395 | return 0;
|
---|
[358] | 396 | else {
|
---|
[551] | 397 | newstdout = -1;
|
---|
| 398 | DosError(FERR_DISABLEHARDERR);
|
---|
| 399 | rc = DosDupHandle(fileno(stdout), &newstdout);
|
---|
| 400 | if (rc) {
|
---|
| 401 | Dos_Error(MB_CANCEL, rc, hwndCnr, pszSrcFile, __LINE__,
|
---|
| 402 | "DosDupHandle");
|
---|
| 403 | return 0;
|
---|
[358] | 404 | }
|
---|
| 405 | else {
|
---|
[551] | 406 | oldstdout = fileno(stdout);
|
---|
| 407 | DosError(FERR_DISABLEHARDERR);
|
---|
| 408 | rc = DosDupHandle(fileno(fp), &oldstdout);
|
---|
| 409 | if (rc) {
|
---|
| 410 | Dos_Error(MB_CANCEL, rc, hwndCnr, pszSrcFile, __LINE__,
|
---|
| 411 | "DosDupHandle");
|
---|
| 412 | return 0;
|
---|
[358] | 413 | }
|
---|
| 414 | else {
|
---|
[551] | 415 | runemf2(SEPARATE | INVISIBLE | FULLSCREEN | BACKGROUND | WAIT,
|
---|
| 416 | hwndCnr, NULL, NULL, "%s %s%s%s", info->list,
|
---|
| 417 | (needs_quoting(arcname)) ? "\"" : NullStr, arcname,
|
---|
| 418 | (needs_quoting(arcname)) ? "\"" : NullStr);
|
---|
| 419 | oldstdout = fileno(stdout);
|
---|
| 420 | DosError(FERR_DISABLEHARDERR);
|
---|
| 421 | DosDupHandle(newstdout, &oldstdout);
|
---|
| 422 | DosClose(newstdout);
|
---|
| 423 | fclose(fp);
|
---|
| 424 | }
|
---|
| 425 | }
|
---|
[2] | 426 | }
|
---|
| 427 | }
|
---|
[300] | 428 |
|
---|
[2] | 429 | DosError(FERR_DISABLEHARDERR);
|
---|
[551] | 430 | fp = _fsopen(arctemp, "r", SH_DENYWR);
|
---|
[300] | 431 |
|
---|
[358] | 432 | if (fp) {
|
---|
[300] | 433 | gotstart = !info->startlist || !*info->startlist; // If list has no start marker
|
---|
| 434 |
|
---|
[551] | 435 | while (!feof(fp) && !gotend && !*pStopFlag) {
|
---|
| 436 | if (!xfgets_bstripcr(s, sizeof(s), fp, pszSrcFile, __LINE__))
|
---|
| 437 | break;
|
---|
| 438 | if (!gotstart) {
|
---|
| 439 | if (!strcmp(s, info->startlist))
|
---|
| 440 | gotstart = TRUE;
|
---|
| 441 | }
|
---|
| 442 | else if (info->endlist && !strcmp(s, info->endlist))
|
---|
| 443 | gotend = TRUE;
|
---|
| 444 | else {
|
---|
[300] | 445 | /* add to container */
|
---|
[551] | 446 | fname = NULL;
|
---|
| 447 | bstrip(s);
|
---|
| 448 | if (info->nameisfirst) {
|
---|
| 449 | strncpy(lonename, s, CCHMAXPATH + 2);
|
---|
| 450 | lonename[CCHMAXPATH + 1] = 0;
|
---|
| 451 | fname = lonename;
|
---|
| 452 | if (!xfgets_bstripcr(s, sizeof(s), fp, pszSrcFile, __LINE__))
|
---|
| 453 | break;
|
---|
| 454 | if (*fname == '\"') {
|
---|
| 455 | memmove(fname, fname + 1, strlen(fname) + 1);
|
---|
| 456 | p = strchr(fname, '\"');
|
---|
| 457 | if (p)
|
---|
| 458 | *p = 0;
|
---|
| 459 | }
|
---|
| 460 | }
|
---|
| 461 | nsize = NULL;
|
---|
| 462 | osize = fdate = NullStr;
|
---|
| 463 | p = s;
|
---|
| 464 | for (x = 0; x <= highest; x++) {
|
---|
| 465 | pp = p;
|
---|
| 466 | while (*pp && (*pp == ' ' || *pp == '\t')) /* skip leading */
|
---|
| 467 | pp++;
|
---|
| 468 | if (!*pp)
|
---|
| 469 | break;
|
---|
| 470 | wasquote = FALSE;
|
---|
| 471 | p = pp;
|
---|
| 472 | while (*p && (wasquote ||
|
---|
| 473 | ((x != info->fnpos || !info->nameislast) ?
|
---|
| 474 | (*p != ' ' && *p != '\t') : TRUE))) {
|
---|
| 475 | if (*p == '\"') {
|
---|
| 476 | if (!wasquote) {
|
---|
| 477 | wasquote = TRUE;
|
---|
| 478 | memmove(p, p + 1, strlen(p));
|
---|
| 479 | while (*p == ' ' || *p == '\t')
|
---|
| 480 | p++;
|
---|
| 481 | }
|
---|
| 482 | else {
|
---|
| 483 | memmove(p, p + 1, strlen(p));
|
---|
| 484 | break;
|
---|
| 485 | }
|
---|
| 486 | }
|
---|
| 487 | else if (*p)
|
---|
| 488 | p++;
|
---|
| 489 | }
|
---|
| 490 | if (*p) {
|
---|
| 491 | *p = 0;
|
---|
| 492 | p++;
|
---|
| 493 | }
|
---|
| 494 | if (x == info->nsizepos)
|
---|
| 495 | nsize = pp;
|
---|
| 496 | else if (x == info->osizepos)
|
---|
| 497 | osize = pp;
|
---|
| 498 | else if (x == info->fdpos) {
|
---|
| 499 | fdate = pp;
|
---|
| 500 | if (info->fdflds > 1 && info->fdflds < 24) {
|
---|
| 501 | INT y;
|
---|
[2] | 502 |
|
---|
[551] | 503 | if (*p) {
|
---|
| 504 | p--;
|
---|
| 505 | *p = ' ';
|
---|
| 506 | for (y = 0; y < info->fdflds - 1; y++) {
|
---|
| 507 | while (*p && (*p == ' ' || *p == '\t'))
|
---|
| 508 | p++;
|
---|
| 509 | while (*p && (*p != ' ' && *p != '\t'))
|
---|
| 510 | p++;
|
---|
| 511 | x++;
|
---|
| 512 | }
|
---|
| 513 | if (*p) {
|
---|
| 514 | *p = 0;
|
---|
| 515 | p++;
|
---|
| 516 | }
|
---|
| 517 | }
|
---|
| 518 | }
|
---|
| 519 | }
|
---|
| 520 | else if (x == info->fnpos) {
|
---|
| 521 | fname = pp;
|
---|
| 522 | if (pp && *pp == '*' && !*(pp + 1)) /* workaround for LH.EXE */
|
---|
| 523 | fname = NULL;
|
---|
| 524 | if (info->nameislast)
|
---|
| 525 | break;
|
---|
| 526 | }
|
---|
| 527 | else if ((!p || !*p) && info->fnpos == -1) {
|
---|
| 528 | fname = pp;
|
---|
| 529 | break;
|
---|
| 530 | }
|
---|
| 531 | }
|
---|
| 532 | if (info->nameisnext) {
|
---|
| 533 | if (!xfgets_bstripcr
|
---|
| 534 | (lonename, sizeof(lonename), fp, pszSrcFile, __LINE__))
|
---|
| 535 | break;
|
---|
| 536 | fname = lonename;
|
---|
| 537 | }
|
---|
[423] | 538 | // fixme to complain?
|
---|
[551] | 539 | if (fname && *fname) {
|
---|
[2] | 540 |
|
---|
[551] | 541 | RECORDINSERT ri;
|
---|
| 542 | PARCITEM pai;
|
---|
[2] | 543 |
|
---|
| 544 | #ifdef DEBUG
|
---|
[551] | 545 | saymsg(MB_ENTER, hwndCnr, DEBUG_STRING,
|
---|
| 546 | "fname: %s\r\rpp: %s\r\rp: %s\r\rlonename: %s\r\rhighest: %ld\r\rx: %ld\r\rfdate: %s",
|
---|
| 547 | (fname) ? fname : "NULL",
|
---|
| 548 | (pp) ? pp : "NULL",
|
---|
| 549 | (p) ? p : "NULL",
|
---|
| 550 | lonename, highest, x, (fdate) ? fdate : "NULL");
|
---|
[2] | 551 | #endif
|
---|
| 552 |
|
---|
[551] | 553 | pai = WinSendMsg(hwndCnr,
|
---|
| 554 | CM_ALLOCRECORD,
|
---|
| 555 | MPFROMLONG(EXTRA_ARCRECORD_BYTES),
|
---|
| 556 | MPFROMLONG(1L));
|
---|
| 557 | if (!pai) {
|
---|
[358] | 558 | Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD");
|
---|
| 559 | break;
|
---|
| 560 | }
|
---|
| 561 | else {
|
---|
[551] | 562 | memset(pai, 0, sizeof(ARCITEM));
|
---|
| 563 | pai->hwndCnr = hwndCnr;
|
---|
| 564 | if (*fname == '*') {
|
---|
| 565 | fname++;
|
---|
| 566 | pai->flags = ARCFLAGS_REALDIR;
|
---|
[358] | 567 | }
|
---|
[551] | 568 | if (fname[strlen(fname) - 1] == '\\' ||
|
---|
| 569 | fname[strlen(fname) - 1] == '/')
|
---|
| 570 | pai->flags = ARCFLAGS_REALDIR;
|
---|
| 571 | strcpy(pai->szFileName, fname);
|
---|
| 572 | if (fdate)
|
---|
| 573 | strcpy(pai->szDate, fdate);
|
---|
| 574 | pai->pszFileName = pai->szFileName;
|
---|
| 575 | pai->rc.pszIcon = pai->pszFileName;
|
---|
| 576 | pai->rc.hptrIcon = ((pai->flags & ARCFLAGS_REALDIR) != 0) ?
|
---|
| 577 | hptrDir : hptrFile;
|
---|
| 578 | pai->pszDate = pai->szDate;
|
---|
| 579 | if (osize)
|
---|
| 580 | pai->cbFile = atol(osize);
|
---|
| 581 | if (nsize)
|
---|
| 582 | pai->cbComp = atol(nsize);
|
---|
| 583 | if (info->datetype && fdate && *fdate)
|
---|
| 584 | ArcDateTime(fdate, info->datetype, &pai->date, &pai->time);
|
---|
| 585 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
| 586 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 587 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
| 588 | ri.pRecordParent = (PRECORDCORE) NULL;
|
---|
| 589 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
| 590 | ri.cRecordsInsert = 1L;
|
---|
| 591 | ri.fInvalidateRecord = FALSE;
|
---|
| 592 | if (WinSendMsg(hwndCnr,
|
---|
| 593 | CM_INSERTRECORD, MPFROMP(pai), MPFROMP(&ri))) {
|
---|
| 594 | *pullTotalBytes += pai->cbFile;
|
---|
| 595 | }
|
---|
| 596 | numarcfiles++;
|
---|
| 597 | if (!(++counter % 50)) {
|
---|
| 598 | if (!lastpai)
|
---|
| 599 | lastpai = pai;
|
---|
| 600 | WinSendMsg(hwndCnr,
|
---|
| 601 | CM_INVALIDATERECORD,
|
---|
| 602 | lastpai,
|
---|
| 603 | MPFROM2SHORT(10, CMA_ERASE | CMA_REPOSITION));
|
---|
| 604 | lastpai = pai;
|
---|
| 605 | }
|
---|
[426] | 606 | // Avoid hogging system for large archive
|
---|
| 607 | if (numarcfiles == 100)
|
---|
[551] | 608 | priority_idle();
|
---|
| 609 | }
|
---|
| 610 | }
|
---|
| 611 | }
|
---|
| 612 | } // while !eof
|
---|
[300] | 613 |
|
---|
[2] | 614 | fclose(fp);
|
---|
[300] | 615 |
|
---|
[426] | 616 | if (*pStopFlag)
|
---|
[551] | 617 | numarcfiles = 0; // Request close
|
---|
| 618 | else if (!numarcfiles || !gotstart
|
---|
| 619 | || (!gotend && info->endlist && *info->endlist)) {
|
---|
[423] | 620 | // Oops
|
---|
[551] | 621 | ARCDUMP ad;
|
---|
| 622 | CHAR errstr[CCHMAXPATH + 256];
|
---|
[2] | 623 |
|
---|
[423] | 624 | // Try for alternate archiver
|
---|
[551] | 625 | tinfo = info;
|
---|
| 626 | do {
|
---|
| 627 | tinfo = tinfo->next;
|
---|
| 628 | if (tinfo)
|
---|
| 629 | tinfo = find_type(arcname, tinfo);
|
---|
| 630 | if (tinfo) {
|
---|
| 631 | DosError(FERR_DISABLEHARDERR);
|
---|
| 632 | DosForceDelete(arctemp);
|
---|
| 633 | info = tinfo;
|
---|
| 634 | goto ReTry;
|
---|
| 635 | }
|
---|
| 636 | } while (tinfo);
|
---|
| 637 | DosBeep(750, 50); // wake up user
|
---|
| 638 | sprintf(errstr, GetPString(IDS_ARCERRORINFOTEXT),
|
---|
| 639 | arcname,
|
---|
| 640 | (!gotstart) ? GetPString(IDS_NOGOTSTARTTEXT) : NullStr,
|
---|
| 641 | (!numarcfiles) ? GetPString(IDS_NOARCFILESFOUNDTEXT) :
|
---|
| 642 | NullStr,
|
---|
| 643 | (!gotend) ? GetPString(IDS_NOENDOFLISTTEXT) : NullStr);
|
---|
| 644 | memset(&ad, 0, sizeof(ARCDUMP));
|
---|
| 645 | ad.info = info;
|
---|
| 646 | strcpy(ad.listname, arctemp);
|
---|
| 647 | strcpy(ad.arcname, arcname);
|
---|
| 648 | ad.errmsg = errstr;
|
---|
| 649 | WinDlgBox(HWND_DESKTOP,
|
---|
| 650 | hwndCnr,
|
---|
| 651 | ArcErrProc, FM3ModHandle, ARCERR_FRAME, MPFROMP(&ad));
|
---|
[2] | 652 | }
|
---|
[249] | 653 | else if (!nomove && tinfo) {
|
---|
| 654 | /* if we got a false hit, move working hit to top */
|
---|
[551] | 655 | tinfo = info->next;
|
---|
| 656 | info->next = arcsighead;
|
---|
| 657 | arcsighead->prev = info;
|
---|
| 658 | if (tinfo)
|
---|
| 659 | tinfo->next->prev = info->prev;
|
---|
| 660 | info->prev->next = tinfo;
|
---|
| 661 | info->prev = NULL;
|
---|
| 662 | arcsighead = info;
|
---|
| 663 | rewrite_archiverbb2(NULL); // Rewrite with warning
|
---|
[2] | 664 | }
|
---|
[551] | 665 | } // if opened
|
---|
[426] | 666 |
|
---|
[2] | 667 | DosError(FERR_DISABLEHARDERR);
|
---|
| 668 | DosForceDelete(arctemp);
|
---|
| 669 | }
|
---|
| 670 |
|
---|
[426] | 671 | if (numarcfiles)
|
---|
[423] | 672 | priority_normal();
|
---|
| 673 |
|
---|
[2] | 674 | return numarcfiles;
|
---|
| 675 | }
|
---|
| 676 |
|
---|
[551] | 677 | MRESULT EXPENTRY ArcTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[172] | 678 | {
|
---|
[551] | 679 | static BOOL emphasized = FALSE;
|
---|
| 680 | static HWND hwndButtonPopup = (HWND) 0;
|
---|
| 681 | static ULONG timestamp = ULONG_MAX;
|
---|
| 682 | static USHORT lastid = 0;
|
---|
[2] | 683 |
|
---|
[551] | 684 | switch (msg) {
|
---|
| 685 | case WM_CREATE:
|
---|
| 686 | return CommonTextProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 687 |
|
---|
[551] | 688 | case WM_COMMAND:
|
---|
| 689 | return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 690 | ARC_CNR), msg, mp1, mp2);
|
---|
[2] | 691 |
|
---|
[551] | 692 | case UM_CONTEXTMENU:
|
---|
| 693 | case WM_CONTEXTMENU:
|
---|
| 694 | {
|
---|
| 695 | USHORT id;
|
---|
[2] | 696 |
|
---|
[551] | 697 | id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
| 698 | switch (id) {
|
---|
| 699 | case DIR_SELECTED:
|
---|
| 700 | case DIR_VIEW:
|
---|
| 701 | case DIR_SORT:
|
---|
| 702 | {
|
---|
| 703 | POINTL ptl = { 0, 0 };
|
---|
| 704 | SWP swp;
|
---|
| 705 | DIRCNRDATA *dcd;
|
---|
[2] | 706 |
|
---|
[551] | 707 | if (hwndButtonPopup)
|
---|
| 708 | WinDestroyWindow(hwndButtonPopup);
|
---|
| 709 | if (id == DIR_SELECTED)
|
---|
| 710 | id = DIR_RESTORE;
|
---|
| 711 | if (id == lastid) {
|
---|
[2] | 712 |
|
---|
[551] | 713 | ULONG check;
|
---|
[2] | 714 |
|
---|
[551] | 715 | DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &check,
|
---|
| 716 | sizeof(check));
|
---|
| 717 | if (check < timestamp + 500) {
|
---|
| 718 | lastid = 0;
|
---|
| 719 | goto MenuAbort;
|
---|
| 720 | }
|
---|
| 721 | }
|
---|
| 722 | hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
|
---|
| 723 | if (hwndButtonPopup) {
|
---|
| 724 | WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
|
---|
| 725 | dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
|
---|
| 726 | QW_PARENT),
|
---|
| 727 | ARC_CNR), QWL_USER);
|
---|
| 728 | if (id == DIR_SORT) {
|
---|
| 729 | if (dcd)
|
---|
| 730 | SetSortChecks(hwndButtonPopup, dcd->sortFlags);
|
---|
| 731 | WinSendMsg(hwndButtonPopup,
|
---|
| 732 | MM_DELETEITEM,
|
---|
| 733 | MPFROM2SHORT(IDM_SORTNONE, FALSE), MPVOID);
|
---|
| 734 | WinSendMsg(hwndButtonPopup,
|
---|
| 735 | MM_DELETEITEM,
|
---|
| 736 | MPFROM2SHORT(IDM_SORTNAME, FALSE), MPVOID);
|
---|
| 737 | WinSendMsg(hwndButtonPopup,
|
---|
| 738 | MM_DELETEITEM,
|
---|
| 739 | MPFROM2SHORT(IDM_SORTLADATE, FALSE), MPVOID);
|
---|
| 740 | WinSendMsg(hwndButtonPopup,
|
---|
| 741 | MM_DELETEITEM,
|
---|
| 742 | MPFROM2SHORT(IDM_SORTCRDATE, FALSE), MPVOID);
|
---|
| 743 | WinSendMsg(hwndButtonPopup,
|
---|
| 744 | MM_DELETEITEM,
|
---|
| 745 | MPFROM2SHORT(IDM_SORTDIRSFIRST, FALSE), MPVOID);
|
---|
| 746 | WinSendMsg(hwndButtonPopup,
|
---|
| 747 | MM_DELETEITEM,
|
---|
| 748 | MPFROM2SHORT(IDM_SORTDIRSLAST, FALSE), MPVOID);
|
---|
| 749 | WinSendMsg(hwndButtonPopup,
|
---|
| 750 | MM_DELETEITEM,
|
---|
| 751 | MPFROM2SHORT(IDM_SORTSUBJECT, FALSE), MPVOID);
|
---|
| 752 | WinSendMsg(hwndButtonPopup,
|
---|
| 753 | MM_SETITEMTEXT,
|
---|
| 754 | MPFROM2SHORT(IDM_SORTEASIZE, 0),
|
---|
| 755 | MPFROMP(GetPString(IDS_COMPRESSEDSIZEMENUTEXT)));
|
---|
| 756 | WinSendMsg(hwndButtonPopup,
|
---|
| 757 | MM_SETITEMTEXT,
|
---|
| 758 | MPFROM2SHORT(IDM_SORTLWDATE, 0),
|
---|
| 759 | MPFROMP(GetPString(IDS_DATEMENUTEXT)));
|
---|
| 760 | }
|
---|
| 761 | ptl.x = 0;
|
---|
| 762 | if (WinPopupMenu(HWND_OBJECT,
|
---|
| 763 | HWND_OBJECT,
|
---|
| 764 | hwndButtonPopup, -32767, -32767, 0, 0)) {
|
---|
| 765 | WinQueryWindowPos(hwndButtonPopup, &swp);
|
---|
| 766 | ptl.y = -(swp.cy + 2);
|
---|
| 767 | }
|
---|
| 768 | else {
|
---|
| 769 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 770 | ptl.y = swp.cy + 2;
|
---|
| 771 | }
|
---|
| 772 | if (WinPopupMenu(hwnd,
|
---|
| 773 | hwnd,
|
---|
| 774 | hwndButtonPopup,
|
---|
| 775 | ptl.x,
|
---|
| 776 | ptl.y,
|
---|
| 777 | 0,
|
---|
| 778 | PU_HCONSTRAIN | PU_VCONSTRAIN |
|
---|
| 779 | PU_KEYBOARD | PU_MOUSEBUTTON1)) {
|
---|
| 780 | CenterOverWindow(hwndButtonPopup);
|
---|
| 781 | PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
|
---|
| 782 | }
|
---|
| 783 | }
|
---|
| 784 | }
|
---|
| 785 | break;
|
---|
| 786 | default:
|
---|
| 787 | PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 788 | ARC_CNR),
|
---|
| 789 | WM_CONTROL, MPFROM2SHORT(ARC_CNR, CN_CONTEXTMENU), MPVOID);
|
---|
| 790 | break;
|
---|
[2] | 791 | }
|
---|
[551] | 792 | }
|
---|
| 793 | MenuAbort:
|
---|
| 794 | if (msg == UM_CONTEXTMENU)
|
---|
| 795 | return 0;
|
---|
| 796 | break;
|
---|
[2] | 797 |
|
---|
[551] | 798 | case WM_MENUEND:
|
---|
| 799 | if (hwndButtonPopup == (HWND) mp2) {
|
---|
| 800 | lastid = WinQueryWindowUShort((HWND) mp2, QWS_ID);
|
---|
| 801 | WinDestroyWindow(hwndButtonPopup);
|
---|
| 802 | hwndButtonPopup = (HWND) 0;
|
---|
| 803 | DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, ×tamp,
|
---|
| 804 | sizeof(timestamp));
|
---|
| 805 | switch (lastid) {
|
---|
| 806 | case DIR_VIEW:
|
---|
| 807 | case DIR_SORT:
|
---|
| 808 | case DIR_RESTORE:
|
---|
| 809 | case DIR_SELECTED:
|
---|
| 810 | PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
|
---|
| 811 | break;
|
---|
[2] | 812 | }
|
---|
[551] | 813 | }
|
---|
| 814 | break;
|
---|
[2] | 815 |
|
---|
[551] | 816 | case WM_MOUSEMOVE:
|
---|
| 817 | {
|
---|
| 818 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
| 819 | char *s = NULL;
|
---|
[2] | 820 |
|
---|
[551] | 821 | if (fOtherHelp) {
|
---|
| 822 | if ((!hwndBubble ||
|
---|
| 823 | WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
|
---|
| 824 | !WinQueryCapture(HWND_DESKTOP)) {
|
---|
| 825 | switch (id) {
|
---|
| 826 | case DIR_TOTALS:
|
---|
| 827 | s = GetPString(IDS_ARCCNRTOTALSHELPTEXT);
|
---|
| 828 | break;
|
---|
| 829 | case DIR_SELECTED:
|
---|
| 830 | s = GetPString(IDS_ARCCNRSELECTEDHELPTEXT);
|
---|
| 831 | break;
|
---|
| 832 | case DIR_VIEW:
|
---|
| 833 | s = GetPString(IDS_ARCCNRVIEWHELPTEXT);
|
---|
| 834 | break;
|
---|
| 835 | case DIR_SORT:
|
---|
| 836 | s = GetPString(IDS_DIRCNRSORTHELP);
|
---|
| 837 | break;
|
---|
| 838 | case DIR_FILTER:
|
---|
| 839 | s = GetPString(IDS_DIRCNRFILTERHELP);
|
---|
| 840 | break;
|
---|
| 841 | case DIR_FOLDERICON:
|
---|
| 842 | s = GetPString(IDS_ARCCNRFOLDERHELPTEXT);
|
---|
| 843 | break;
|
---|
| 844 | default:
|
---|
| 845 | break;
|
---|
| 846 | }
|
---|
| 847 | if (s)
|
---|
| 848 | MakeBubble(hwnd, TRUE, s);
|
---|
| 849 | else if (hwndBubble)
|
---|
| 850 | WinDestroyWindow(hwndBubble);
|
---|
| 851 | }
|
---|
[2] | 852 | }
|
---|
[551] | 853 | switch (id) {
|
---|
| 854 | case DIR_FILTER:
|
---|
| 855 | case DIR_SORT:
|
---|
| 856 | case DIR_VIEW:
|
---|
| 857 | case DIR_SELECTED:
|
---|
| 858 | case DIR_FOLDERICON:
|
---|
| 859 | return CommonTextButton(hwnd, msg, mp1, mp2);
|
---|
| 860 | }
|
---|
| 861 | }
|
---|
| 862 | break;
|
---|
[2] | 863 |
|
---|
[551] | 864 | case WM_BUTTON3UP:
|
---|
| 865 | case WM_BUTTON1UP:
|
---|
| 866 | case WM_BUTTON1DOWN:
|
---|
| 867 | case WM_BUTTON3DOWN:
|
---|
| 868 | {
|
---|
| 869 | USHORT id;
|
---|
[2] | 870 |
|
---|
[551] | 871 | id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
| 872 | switch (id) {
|
---|
| 873 | case DIR_FILTER:
|
---|
| 874 | case DIR_SORT:
|
---|
| 875 | case DIR_VIEW:
|
---|
| 876 | case DIR_SELECTED:
|
---|
| 877 | case DIR_FOLDERICON:
|
---|
| 878 | return CommonTextButton(hwnd, msg, mp1, mp2);
|
---|
[2] | 879 | }
|
---|
[551] | 880 | }
|
---|
| 881 | break;
|
---|
[2] | 882 |
|
---|
[551] | 883 | case UM_CLICKED:
|
---|
| 884 | case UM_CLICKED3:
|
---|
| 885 | {
|
---|
| 886 | USHORT id, cmd = 0;
|
---|
[2] | 887 |
|
---|
[551] | 888 | id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
| 889 | switch (id) {
|
---|
| 890 | case DIR_FOLDERICON:
|
---|
| 891 | switch (msg) {
|
---|
| 892 | case WM_BUTTON3CLICK:
|
---|
| 893 | case WM_CHORD:
|
---|
| 894 | cmd = IDM_RESCAN;
|
---|
| 895 | break;
|
---|
| 896 | default:
|
---|
| 897 | if ((SHORT2FROMMP(mp2) & KC_ALT) != 0)
|
---|
| 898 | cmd = IDM_WINDOWDLG;
|
---|
| 899 | else
|
---|
| 900 | cmd = IDM_WALKDIR;
|
---|
| 901 | break;
|
---|
| 902 | }
|
---|
| 903 | break;
|
---|
| 904 | case DIR_VIEW:
|
---|
| 905 | case DIR_SORT:
|
---|
| 906 | case DIR_SELECTED:
|
---|
| 907 | PostMsg(hwnd, UM_CONTEXTMENU, MPVOID, MPVOID);
|
---|
| 908 | break;
|
---|
| 909 | case DIR_FILTER:
|
---|
| 910 | cmd = IDM_FILTER;
|
---|
| 911 | break;
|
---|
| 912 | default:
|
---|
| 913 | break;
|
---|
[2] | 914 | }
|
---|
[551] | 915 | if (cmd)
|
---|
| 916 | PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 917 | ARC_CNR),
|
---|
| 918 | WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
|
---|
| 919 | }
|
---|
| 920 | return 0;
|
---|
[2] | 921 |
|
---|
[551] | 922 | case WM_BEGINDRAG:
|
---|
| 923 | case DM_DROP:
|
---|
| 924 | case DM_DRAGOVER:
|
---|
| 925 | case DM_DRAGLEAVE:
|
---|
| 926 | case DM_DROPHELP:
|
---|
| 927 | if (msg == DM_DRAGOVER) {
|
---|
| 928 | if (!emphasized) {
|
---|
| 929 | emphasized = TRUE;
|
---|
| 930 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
[2] | 931 | }
|
---|
[551] | 932 | }
|
---|
| 933 | else if (msg != WM_BEGINDRAG) {
|
---|
| 934 | if (emphasized) {
|
---|
| 935 | emphasized = FALSE;
|
---|
| 936 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
[2] | 937 | }
|
---|
[551] | 938 | }
|
---|
| 939 | switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
|
---|
| 940 | case DIR_FOLDERICON:
|
---|
| 941 | switch (msg) {
|
---|
| 942 | case DM_DRAGOVER:
|
---|
| 943 | if (AcceptOneDrop(mp1, mp2))
|
---|
| 944 | return MRFROM2SHORT(DOR_DROP, DO_MOVE);
|
---|
| 945 | return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
|
---|
| 946 | case DM_DROPHELP:
|
---|
| 947 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_ARCCNRFOLDERDROPHELPTEXT));
|
---|
| 948 | return 0;
|
---|
| 949 | case DM_DROP:
|
---|
| 950 | {
|
---|
| 951 | char szFrom[CCHMAXPATH + 2];
|
---|
[2] | 952 |
|
---|
[551] | 953 | if (emphasized) {
|
---|
| 954 | emphasized = FALSE;
|
---|
| 955 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
| 956 | }
|
---|
| 957 | if (GetOneDrop(mp1, mp2, szFrom, sizeof(szFrom)))
|
---|
| 958 | WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 959 | ARC_CNR),
|
---|
| 960 | WM_COMMAND,
|
---|
| 961 | MPFROM2SHORT(IDM_SWITCH, 0), MPFROMP(szFrom));
|
---|
| 962 | }
|
---|
| 963 | return 0;
|
---|
| 964 | default:
|
---|
| 965 | return PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
| 966 | }
|
---|
| 967 | default:
|
---|
| 968 | {
|
---|
| 969 | CNRDRAGINFO cnd;
|
---|
| 970 | USHORT dcmd;
|
---|
[2] | 971 |
|
---|
[551] | 972 | switch (msg) {
|
---|
| 973 | case DM_DROP:
|
---|
| 974 | dcmd = CN_DROP;
|
---|
| 975 | break;
|
---|
| 976 | case DM_DRAGOVER:
|
---|
| 977 | dcmd = CN_DRAGOVER;
|
---|
| 978 | break;
|
---|
| 979 | case DM_DRAGLEAVE:
|
---|
| 980 | dcmd = CN_DRAGLEAVE;
|
---|
| 981 | break;
|
---|
| 982 | case DM_DROPHELP:
|
---|
| 983 | dcmd = CN_DROPHELP;
|
---|
| 984 | break;
|
---|
| 985 | case WM_BEGINDRAG:
|
---|
| 986 | dcmd = CN_INITDRAG;
|
---|
| 987 | break;
|
---|
| 988 | }
|
---|
| 989 | cnd.pDragInfo = (PDRAGINFO) mp1;
|
---|
| 990 | cnd.pRecord = NULL;
|
---|
| 991 | return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 992 | WM_CONTROL,
|
---|
| 993 | MPFROM2SHORT(ARC_CNR, dcmd), MPFROMP(&cnd));
|
---|
[2] | 994 | }
|
---|
[551] | 995 | }
|
---|
[2] | 996 | }
|
---|
[551] | 997 | return PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
[2] | 998 | }
|
---|
| 999 |
|
---|
[551] | 1000 | MRESULT EXPENTRY ArcClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 1001 | MPARAM mp2)
|
---|
| 1002 | {
|
---|
[2] | 1003 |
|
---|
[551] | 1004 | switch (msg) {
|
---|
| 1005 | case UM_CONTAINERHWND:
|
---|
| 1006 | return MRFROMLONG(WinWindowFromID(hwnd, ARC_CNR));
|
---|
[2] | 1007 |
|
---|
[551] | 1008 | case UM_VIEWSMENU:
|
---|
| 1009 | // fixme to disble menu items as needed
|
---|
| 1010 | return MRFROMLONG(CheckMenu(&ArcCnrMenu, ARCCNR_POPUP));
|
---|
[2] | 1011 |
|
---|
[551] | 1012 | case UM_FILESMENU:
|
---|
| 1013 | // fixme to disble menu items as needed
|
---|
| 1014 | return MRFROMLONG(CheckMenu(&ArcMenu, ARC_POPUP));
|
---|
[2] | 1015 |
|
---|
[551] | 1016 | case MM_PORTHOLEINIT:
|
---|
| 1017 | case WM_INITMENU:
|
---|
| 1018 | case UM_INITMENU:
|
---|
| 1019 | case UM_COMMAND:
|
---|
| 1020 | case UM_LOADFILE:
|
---|
| 1021 | case UM_UPDATERECORD:
|
---|
| 1022 | case UM_UPDATERECORDLIST:
|
---|
| 1023 | case WM_COMMAND:
|
---|
| 1024 | case WM_CONTROL:
|
---|
| 1025 | case WM_CLOSE:
|
---|
| 1026 | return WinSendMsg(WinWindowFromID(hwnd, ARC_CNR), msg, mp1, mp2);
|
---|
[2] | 1027 |
|
---|
[551] | 1028 | case WM_PSETFOCUS:
|
---|
| 1029 | case WM_SETFOCUS:
|
---|
| 1030 | if (mp2)
|
---|
| 1031 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
|
---|
| 1032 | break;
|
---|
[2] | 1033 |
|
---|
[551] | 1034 | case UM_FOCUSME:
|
---|
| 1035 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, ARC_CNR));
|
---|
| 1036 | break;
|
---|
[2] | 1037 |
|
---|
[551] | 1038 | case WM_PAINT:
|
---|
| 1039 | {
|
---|
| 1040 | HPS hps;
|
---|
| 1041 | RECTL rcl;
|
---|
[2] | 1042 |
|
---|
[551] | 1043 | hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
|
---|
| 1044 | if (hps) {
|
---|
| 1045 | WinQueryWindowRect(hwnd, &rcl);
|
---|
| 1046 | WinFillRect(hps, &rcl, CLR_PALEGRAY);
|
---|
| 1047 | CommonTextPaint(hwnd, hps);
|
---|
| 1048 | WinEndPaint(hps);
|
---|
[2] | 1049 | }
|
---|
[551] | 1050 | }
|
---|
| 1051 | break;
|
---|
[2] | 1052 |
|
---|
[551] | 1053 | case UM_SIZE:
|
---|
| 1054 | case WM_SIZE:
|
---|
| 1055 | if (msg == UM_SIZE) {
|
---|
[2] | 1056 |
|
---|
[551] | 1057 | SWP swp;
|
---|
[2] | 1058 |
|
---|
[551] | 1059 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 1060 | mp1 = MPFROM2SHORT(swp.cx, swp.cy);
|
---|
| 1061 | mp2 = MPFROM2SHORT(swp.cx, swp.cy);
|
---|
| 1062 | }
|
---|
| 1063 | {
|
---|
| 1064 | USHORT cx, cy, bx;
|
---|
[2] | 1065 |
|
---|
[551] | 1066 | cx = SHORT1FROMMP(mp2);
|
---|
| 1067 | cy = SHORT2FROMMP(mp2);
|
---|
| 1068 | WinSetWindowPos(WinWindowFromID(hwnd, ARC_CNR), HWND_TOP,
|
---|
| 1069 | 0,
|
---|
| 1070 | 22, cx, cy - (24 + 22), SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1071 | WinSetWindowPos(WinWindowFromID(hwnd, ARC_EXTRACTDIR), HWND_TOP,
|
---|
| 1072 | 0, 0, cx, 22, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1073 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_FOLDERICON), HWND_TOP,
|
---|
| 1074 | 2, cy - 22, 24, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1075 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_TOTALS), HWND_TOP,
|
---|
| 1076 | 29,
|
---|
| 1077 | cy - 22,
|
---|
| 1078 | (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1079 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_SELECTED), HWND_TOP,
|
---|
| 1080 | 29 + (cx / 3) + 2,
|
---|
| 1081 | cy - 22,
|
---|
| 1082 | (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1083 | bx = (cx - (29 + (((cx / 3) + 2) * 2))) / 3;
|
---|
| 1084 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_VIEW), HWND_TOP,
|
---|
| 1085 | 29 + (((cx / 3) + 2) * 2),
|
---|
| 1086 | cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1087 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_SORT), HWND_TOP,
|
---|
| 1088 | 29 + (((cx / 3) + 2) * 2) + bx,
|
---|
| 1089 | cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1090 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_FILTER), HWND_TOP,
|
---|
| 1091 | 29 + (((cx / 3) + 2) * 2) + (bx * 2),
|
---|
| 1092 | cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1093 | }
|
---|
| 1094 | CommonTextPaint(hwnd, (HPS) 0);
|
---|
| 1095 | if (msg == UM_SIZE) {
|
---|
| 1096 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
|
---|
| 1097 | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
|
---|
| 1098 | return 0;
|
---|
| 1099 | }
|
---|
| 1100 | break;
|
---|
[2] | 1101 | }
|
---|
[551] | 1102 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1103 | }
|
---|
| 1104 |
|
---|
[551] | 1105 | MRESULT EXPENTRY ArcObjWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[172] | 1106 | {
|
---|
[2] | 1107 | DIRCNRDATA *dcd;
|
---|
[358] | 1108 | PSZ psz;
|
---|
[2] | 1109 |
|
---|
[551] | 1110 | switch (msg) {
|
---|
| 1111 | case DM_PRINTOBJECT:
|
---|
| 1112 | case DM_DISCARDOBJECT:
|
---|
| 1113 | dcd = INSTDATA(hwnd);
|
---|
| 1114 | if (dcd) {
|
---|
[2] | 1115 |
|
---|
[551] | 1116 | LISTINFO *li;
|
---|
| 1117 | CNRDRAGINFO cni;
|
---|
[2] | 1118 |
|
---|
[551] | 1119 | cni.pRecord = NULL;
|
---|
| 1120 | cni.pDragInfo = (PDRAGINFO) mp1;
|
---|
| 1121 | li = DoFileDrop(dcd->hwndCnr,
|
---|
| 1122 | dcd->directory, FALSE, MPVOID, MPFROMP(&cni));
|
---|
| 1123 | if (li) {
|
---|
| 1124 | li->type = (msg == DM_DISCARDOBJECT) ? IDM_DELETE : IDM_PRINT;
|
---|
| 1125 | if (!li->list ||
|
---|
| 1126 | !li->list[0] || !PostMsg(hwnd, UM_ACTION, MPFROMP(li), MPVOID))
|
---|
| 1127 | FreeListInfo(li);
|
---|
| 1128 | else
|
---|
| 1129 | return MRFROMLONG(DRR_SOURCE);
|
---|
[2] | 1130 | }
|
---|
[551] | 1131 | }
|
---|
| 1132 | return MRFROMLONG(DRR_TARGET);
|
---|
[2] | 1133 |
|
---|
[551] | 1134 | case DM_RENDERPREPARE:
|
---|
| 1135 | return (MRESULT) TRUE;
|
---|
[2] | 1136 |
|
---|
[551] | 1137 | case DM_RENDER:
|
---|
| 1138 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1139 | if (dcd && dcd->info && dcd->info->extract && dcd->arcname) {
|
---|
[2] | 1140 |
|
---|
[551] | 1141 | PDRAGTRANSFER pdt = (PDRAGTRANSFER) mp1;
|
---|
| 1142 | CHAR filename[CCHMAXPATH];
|
---|
| 1143 | ULONG len;
|
---|
[2] | 1144 |
|
---|
[551] | 1145 | if (pdt->hwndClient && pdt->pditem && pdt->hstrSelectedRMF &&
|
---|
| 1146 | pdt->hstrRenderToName) {
|
---|
| 1147 | if (pdt->usOperation == DO_COPY || pdt->usOperation == DO_MOVE) {
|
---|
| 1148 | *filename = 0;
|
---|
| 1149 | len = DrgQueryStrName(pdt->hstrSelectedRMF, CCHMAXPATH, filename);
|
---|
| 1150 | filename[len] = 0;
|
---|
| 1151 | if (!strnicmp(filename, "OS2FILE,", 8)) {
|
---|
| 1152 | // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"RMF = \"%s\"",filename);
|
---|
| 1153 | }
|
---|
| 1154 | else {
|
---|
| 1155 | *filename = 0;
|
---|
| 1156 | len =
|
---|
| 1157 | DrgQueryStrName(pdt->hstrRenderToName, CCHMAXPATH, filename);
|
---|
| 1158 | filename[len] = 0;
|
---|
| 1159 | if (len && *filename) {
|
---|
| 1160 | psz = xstrdup(filename, pszSrcFile, __LINE__);
|
---|
| 1161 | if (psz) {
|
---|
| 1162 | PostMsg(hwnd, UM_RENDER, MPFROMP(pdt), MPFROMP(psz));
|
---|
| 1163 | return (MRESULT) TRUE;
|
---|
| 1164 | }
|
---|
| 1165 | }
|
---|
[358] | 1166 | else {
|
---|
[551] | 1167 | // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"No render-to name given.");
|
---|
[358] | 1168 | }
|
---|
| 1169 | }
|
---|
[551] | 1170 | }
|
---|
| 1171 | pdt->fsReply = DMFL_RENDERRETRY;
|
---|
[2] | 1172 | }
|
---|
[551] | 1173 | }
|
---|
| 1174 | return (MRESULT) FALSE;
|
---|
[2] | 1175 |
|
---|
[551] | 1176 | case UM_RENDER:
|
---|
| 1177 | {
|
---|
| 1178 | PDRAGTRANSFER pdt = (PDRAGTRANSFER) mp1;
|
---|
| 1179 | USHORT usRes = DMFL_RENDERFAIL;
|
---|
[2] | 1180 |
|
---|
[551] | 1181 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1182 | if (dcd && dcd->info && dcd->info->extract && dcd->arcname) {
|
---|
[2] | 1183 |
|
---|
[551] | 1184 | CHAR *filename = (CHAR *) mp2, *p;
|
---|
| 1185 | ULONG len;
|
---|
| 1186 | CHAR membername[CCHMAXPATH], construct[CCHMAXPATH * 2];
|
---|
[2] | 1187 |
|
---|
[551] | 1188 | *membername = 0;
|
---|
| 1189 | len = DrgQueryStrName(pdt->pditem->hstrSourceName,
|
---|
| 1190 | CCHMAXPATH, membername);
|
---|
| 1191 | membername[len] = 0;
|
---|
| 1192 | if (*membername && len && filename) {
|
---|
| 1193 | unlinkf("%s", filename);
|
---|
| 1194 | strcpy(construct, filename);
|
---|
| 1195 | p = strrchr(filename, '\\');
|
---|
| 1196 | if (!p)
|
---|
| 1197 | *construct = 0;
|
---|
| 1198 | else {
|
---|
| 1199 | if (p == filename || *(p - 1) == ':')
|
---|
| 1200 | p++;
|
---|
| 1201 | *p = 0;
|
---|
| 1202 | }
|
---|
| 1203 | // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"%s %s %s\r[%s]",dcd->info->extract,dcd->arcname,membername,construct);
|
---|
| 1204 | runemf2(SEPARATE | WINDOWED | WAIT |
|
---|
| 1205 | ((fArcStuffVisible) ? 0 : (BACKGROUND | MINIMIZED)) |
|
---|
| 1206 | WAIT, dcd->hwndClient, construct, NULL, "%s %s%s%s %s%s%s",
|
---|
| 1207 | dcd->info->extract,
|
---|
| 1208 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr,
|
---|
| 1209 | dcd->arcname,
|
---|
| 1210 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr,
|
---|
| 1211 | (needs_quoting(membername)) ? "\"" : NullStr,
|
---|
| 1212 | membername, (needs_quoting(membername)) ? "\"" : NullStr);
|
---|
| 1213 | if (*construct && construct[strlen(construct) - 1] != '\\')
|
---|
| 1214 | strcat(construct, "\\");
|
---|
| 1215 | strcat(construct, membername);
|
---|
| 1216 | if (IsFile(construct) != -1) {
|
---|
| 1217 | rename(construct, filename);
|
---|
| 1218 | unlinkf("%s", construct);
|
---|
| 1219 | if (IsFile(filename) != -1)
|
---|
| 1220 | usRes = DMFL_RENDEROK;
|
---|
| 1221 | }
|
---|
| 1222 | }
|
---|
[2] | 1223 | }
|
---|
[551] | 1224 | if (mp2)
|
---|
| 1225 | free((CHAR *) mp2);
|
---|
| 1226 | PostMsg(pdt->hwndClient, DM_RENDERCOMPLETE, MPFROMP(pdt),
|
---|
| 1227 | MPFROM2SHORT(usRes, 0));
|
---|
| 1228 | }
|
---|
| 1229 | return 0;
|
---|
[2] | 1230 |
|
---|
[551] | 1231 | case UM_SETUP:
|
---|
| 1232 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1233 | if (!dcd) {
|
---|
| 1234 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 1235 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 1236 | }
|
---|
| 1237 | else {
|
---|
| 1238 | /* set unique id */
|
---|
| 1239 | WinSetWindowUShort(hwnd, QWS_ID, ARCOBJ_FRAME + (ARC_FRAME - dcd->id));
|
---|
| 1240 | dcd->hwndObject = hwnd; // pass back hwnd
|
---|
| 1241 | if (ParentIsDesktop(hwnd, dcd->hwndParent))
|
---|
| 1242 | DosSleep(250); // Avoid race?
|
---|
| 1243 | }
|
---|
| 1244 | return 0;
|
---|
| 1245 |
|
---|
| 1246 | case UM_RESCAN:
|
---|
| 1247 | /*
|
---|
| 1248 | * populate container
|
---|
| 1249 | */
|
---|
| 1250 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1251 | if (dcd) {
|
---|
| 1252 | if (mp1)
|
---|
| 1253 | strcpy(dcd->arcname, (CHAR *) mp1); // Update name on request
|
---|
| 1254 | dcd->ullTotalBytes = dcd->totalfiles =
|
---|
| 1255 | dcd->selectedfiles = dcd->selectedbytes = 0;
|
---|
| 1256 | WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0");
|
---|
| 1257 | WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k");
|
---|
| 1258 | dcd->totalfiles = FillArcCnr(dcd->hwndCnr,
|
---|
| 1259 | dcd->arcname,
|
---|
| 1260 | &dcd->info,
|
---|
| 1261 | &dcd->ullTotalBytes, &dcd->stopflag);
|
---|
| 1262 | if (!dcd->totalfiles)
|
---|
| 1263 | PostMsg(dcd->hwndCnr, WM_CLOSE, MPVOID, MPVOID);
|
---|
[423] | 1264 | else {
|
---|
[551] | 1265 | dcd->arcfilled = TRUE;
|
---|
| 1266 | if (!PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID))
|
---|
| 1267 | WinSendMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 1268 | PostMsg(dcd->hwndCnr, UM_SETUP2, MPVOID, MPVOID);
|
---|
| 1269 | WinSendMsg(dcd->hwndCnr,
|
---|
| 1270 | CM_INVALIDATERECORD,
|
---|
| 1271 | MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
|
---|
[2] | 1272 | }
|
---|
[551] | 1273 | }
|
---|
| 1274 | return 0;
|
---|
[2] | 1275 |
|
---|
[551] | 1276 | case UM_SELECT:
|
---|
| 1277 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1278 | if (dcd) {
|
---|
| 1279 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 1280 | case IDM_SELECTALL:
|
---|
| 1281 | case IDM_SELECTALLFILES:
|
---|
| 1282 | SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, TRUE);
|
---|
| 1283 | break;
|
---|
| 1284 | case IDM_DESELECTALL:
|
---|
| 1285 | case IDM_DESELECTALLFILES:
|
---|
| 1286 | DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, TRUE);
|
---|
| 1287 | break;
|
---|
| 1288 | case IDM_DESELECTMASK:
|
---|
| 1289 | case IDM_SELECTMASK:
|
---|
| 1290 | {
|
---|
| 1291 | MASK mask;
|
---|
| 1292 | PARCITEM pci = (PARCITEM) mp2;
|
---|
[2] | 1293 |
|
---|
[551] | 1294 | memset(&mask, 0, sizeof(MASK));
|
---|
| 1295 | mask.fNoAttribs = TRUE;
|
---|
| 1296 | mask.fNoDirs = TRUE;
|
---|
| 1297 | strcpy(mask.prompt,
|
---|
| 1298 | GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
|
---|
| 1299 | IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
|
---|
| 1300 | if (pci && (INT) pci != -1)
|
---|
| 1301 | strcpy(mask.szMask, pci->szFileName);
|
---|
| 1302 | if (WinDlgBox(HWND_DESKTOP, dcd->hwndCnr, PickMaskDlgProc,
|
---|
| 1303 | FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
|
---|
| 1304 | if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
|
---|
| 1305 | SelectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, NULL, FALSE);
|
---|
| 1306 | else
|
---|
| 1307 | DeselectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, NULL, FALSE);
|
---|
| 1308 | }
|
---|
| 1309 | }
|
---|
[2] | 1310 |
|
---|
[551] | 1311 | case IDM_INVERT:
|
---|
| 1312 | InvertAll(dcd->hwndCnr);
|
---|
| 1313 | break;
|
---|
[2] | 1314 | }
|
---|
[551] | 1315 | }
|
---|
| 1316 | return 0;
|
---|
[2] | 1317 |
|
---|
[551] | 1318 | case UM_ENTER:
|
---|
| 1319 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1320 | if (dcd) {
|
---|
[2] | 1321 |
|
---|
[551] | 1322 | CHAR *s = (CHAR *) mp1, *p, *pp, filename[CCHMAXPATH];
|
---|
[2] | 1323 |
|
---|
[551] | 1324 | if (s) {
|
---|
| 1325 | if (!dcd->info->extract) {
|
---|
| 1326 | Runtime_Error(pszSrcFile, __LINE__, "no extract");
|
---|
| 1327 | free(s);
|
---|
| 1328 | return 0;
|
---|
| 1329 | }
|
---|
| 1330 | runemf2(SEPARATE | WINDOWED |
|
---|
| 1331 | ((fArcStuffVisible) ? 0 : (BACKGROUND | MINIMIZED)) |
|
---|
| 1332 | WAIT, dcd->hwndClient, dcd->workdir, NULL, "%s %s%s%s %s%s%s",
|
---|
| 1333 | ((dcd->info->exwdirs) ? dcd->info->exwdirs :
|
---|
| 1334 | dcd->info->extract),
|
---|
| 1335 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr,
|
---|
| 1336 | dcd->arcname,
|
---|
| 1337 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr,
|
---|
| 1338 | (needs_quoting(s)) ? "\"" : NullStr,
|
---|
| 1339 | s, (needs_quoting(s)) ? "\"" : NullStr);
|
---|
[2] | 1340 |
|
---|
[551] | 1341 | if (!dcd->info->exwdirs) {
|
---|
| 1342 | p = s;
|
---|
| 1343 | p = strrchr(s, '\\');
|
---|
| 1344 | pp = strrchr(s, '/');
|
---|
| 1345 | if (p && pp)
|
---|
| 1346 | p = max(p, pp);
|
---|
| 1347 | else if (!p)
|
---|
| 1348 | p = pp;
|
---|
| 1349 | if (p)
|
---|
| 1350 | memmove(s, p + 1, strlen(p + 1));
|
---|
| 1351 | }
|
---|
| 1352 | sprintf(filename, "%s\\%s", dcd->workdir, s);
|
---|
| 1353 | p = filename;
|
---|
| 1354 | while (*p) {
|
---|
| 1355 | if (*p == '/')
|
---|
| 1356 | *p = '\\';
|
---|
| 1357 | p++;
|
---|
| 1358 | }
|
---|
| 1359 | free(s);
|
---|
| 1360 | if (IsFile(filename) == 1)
|
---|
| 1361 | WinSendMsg(dcd->hwndCnr, UM_ENTER, MPFROMP(filename), MPVOID);
|
---|
[2] | 1362 | }
|
---|
[551] | 1363 | }
|
---|
| 1364 | return 0;
|
---|
[2] | 1365 |
|
---|
[551] | 1366 | case UM_COMMAND:
|
---|
| 1367 | if (mp1) {
|
---|
| 1368 | if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
|
---|
| 1369 | return (MRESULT) TRUE;
|
---|
| 1370 | }
|
---|
| 1371 | return 0;
|
---|
[2] | 1372 |
|
---|
[551] | 1373 | case UM_ACTION:
|
---|
| 1374 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1375 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1376 | if (dcd) {
|
---|
[2] | 1377 |
|
---|
[551] | 1378 | LISTINFO *li = (LISTINFO *) mp1;
|
---|
| 1379 | register INT x;
|
---|
[2] | 1380 |
|
---|
[551] | 1381 | if (li && li->list && li->list[0]) {
|
---|
| 1382 | switch (li->type) {
|
---|
| 1383 | case IDM_ARCHIVE:
|
---|
| 1384 | case IDM_ARCHIVEM:
|
---|
| 1385 | {
|
---|
| 1386 | DIRCNRDATA ad;
|
---|
| 1387 | CHAR szBuffer[1025], *p;
|
---|
[2] | 1388 |
|
---|
[551] | 1389 | if (!li->list[1] && !stricmp(li->list[0], dcd->arcname)) {
|
---|
| 1390 | Runtime_Error(pszSrcFile, __LINE__, "arc to self");
|
---|
| 1391 | break;
|
---|
| 1392 | }
|
---|
| 1393 | ad = *dcd;
|
---|
| 1394 | ad.namecanchange = 0;
|
---|
| 1395 | ad.fmoving = (li->type == IDM_ARCHIVEM);
|
---|
| 1396 | if (!WinDlgBox(HWND_DESKTOP, dcd->hwndClient, ArchiveDlgProc, FM3ModHandle, ARCH_FRAME, (PVOID) & ad) || !*ad.arcname || !*ad.command) /* we blew it */
|
---|
| 1397 | break;
|
---|
| 1398 | /* build the sucker */
|
---|
| 1399 | strcpy(szBuffer, ad.command);
|
---|
| 1400 | strcat(szBuffer, " ");
|
---|
| 1401 | if (needs_quoting(ad.arcname))
|
---|
| 1402 | strcat(szBuffer, "\"");
|
---|
| 1403 | strcat(szBuffer, ad.arcname);
|
---|
| 1404 | if (needs_quoting(ad.arcname))
|
---|
| 1405 | strcat(szBuffer, "\"");
|
---|
| 1406 | p = &szBuffer[strlen(szBuffer)];
|
---|
| 1407 | if (ad.mask.szMask) {
|
---|
| 1408 | strcat(szBuffer, " ");
|
---|
| 1409 | if (needs_quoting(ad.mask.szMask))
|
---|
| 1410 | strcat(szBuffer, "\"");
|
---|
| 1411 | strcat(szBuffer, ad.mask.szMask);
|
---|
| 1412 | if (needs_quoting(ad.mask.szMask))
|
---|
| 1413 | strcat(szBuffer, "\"");
|
---|
| 1414 | }
|
---|
| 1415 | strcat(szBuffer, " ");
|
---|
| 1416 | x = 0;
|
---|
| 1417 | while (li->list[x]) {
|
---|
| 1418 | if (needs_quoting(li->list[x]))
|
---|
| 1419 | strcat(szBuffer, "\"");
|
---|
| 1420 | strcat(szBuffer, li->list[x]);
|
---|
| 1421 | if (!IsFile(li->list[x])) {
|
---|
| 1422 | if (szBuffer[strlen(szBuffer) - 1] != '\\')
|
---|
| 1423 | strcat(szBuffer, "\\");
|
---|
| 1424 | strcat(szBuffer, "*");
|
---|
| 1425 | }
|
---|
| 1426 | if (needs_quoting(li->list[x]))
|
---|
| 1427 | strcat(szBuffer, "\"");
|
---|
| 1428 | x++;
|
---|
| 1429 | if (!li->list[x] || strlen(szBuffer) +
|
---|
| 1430 | strlen(li->list[x]) + 5 > 1024) {
|
---|
| 1431 | runemf2(SEPARATE | WINDOWED |
|
---|
| 1432 | ((fArcStuffVisible) ? 0 :
|
---|
| 1433 | (BACKGROUND | MINIMIZED)) |
|
---|
| 1434 | WAIT, hwnd, NULL, NULL, "%s", szBuffer);
|
---|
| 1435 | *p = 0;
|
---|
| 1436 | }
|
---|
| 1437 | strcat(szBuffer, " ");
|
---|
| 1438 | }
|
---|
| 1439 | PostMsg(dcd->hwndCnr, UM_RESCAN, MPFROMSHORT(1), MPVOID);
|
---|
| 1440 | Broadcast(WinQueryAnchorBlock(hwnd),
|
---|
| 1441 | hwndMain, UM_UPDATERECORD, MPFROMP(ad.arcname), MPVOID);
|
---|
| 1442 | Broadcast(WinQueryAnchorBlock(hwnd),
|
---|
| 1443 | hwndMain,
|
---|
| 1444 | UM_UPDATERECORDLIST, MPFROMP(li->list), MPVOID);
|
---|
| 1445 | }
|
---|
| 1446 | break;
|
---|
[2] | 1447 |
|
---|
[551] | 1448 | case IDM_REFRESH:
|
---|
| 1449 | case IDM_DELETE:
|
---|
| 1450 | {
|
---|
| 1451 | CHAR cl[1001], *endofit;
|
---|
| 1452 | INT z;
|
---|
| 1453 | CHECKLIST ck;
|
---|
| 1454 | CHAR prompt[CCHMAXPATH + 257];
|
---|
[2] | 1455 |
|
---|
[551] | 1456 | if (!dcd->info->delete)
|
---|
| 1457 | break;
|
---|
| 1458 | memset(&ck, 0, sizeof(ck));
|
---|
| 1459 | ck.size = sizeof(ck);
|
---|
| 1460 | ck.list = li->list;
|
---|
| 1461 | ck.cmd = li->type;
|
---|
| 1462 | ck.prompt = prompt;
|
---|
| 1463 | sprintf(prompt, GetPString(IDS_ARCCNRDELREFTEXT),
|
---|
| 1464 | (li->type == IDM_DELETE) ?
|
---|
| 1465 | GetPString(IDS_DELETELOWERTEXT) :
|
---|
| 1466 | GetPString(IDS_REFRESHLOWERTEXT),
|
---|
| 1467 | &"s"[li->list[1] == NULL],
|
---|
| 1468 | dcd->arcname,
|
---|
| 1469 | (li->type == IDM_DELETE) ?
|
---|
| 1470 | GetPString(IDS_DELETELOWERTEXT) :
|
---|
| 1471 | GetPString(IDS_REFRESHLOWERTEXT));
|
---|
| 1472 | if (!WinDlgBox(HWND_DESKTOP, hwnd, CheckListProc,
|
---|
| 1473 | FM3ModHandle, CHECK_FRAME, MPFROMP(&ck)))
|
---|
| 1474 | break;
|
---|
| 1475 | li->list = ck.list;
|
---|
| 1476 | if (!li->list || !li->list[0])
|
---|
| 1477 | break;
|
---|
| 1478 | if (li->type == IDM_DELETE)
|
---|
| 1479 | sprintf(cl, "%s %s%s%s", dcd->info->delete,
|
---|
| 1480 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr,
|
---|
| 1481 | dcd->arcname,
|
---|
| 1482 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr);
|
---|
| 1483 | else
|
---|
| 1484 | sprintf(cl, "%s %s%s%s", dcd->info->create,
|
---|
| 1485 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr,
|
---|
| 1486 | dcd->arcname,
|
---|
| 1487 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr);
|
---|
| 1488 | endofit = &cl[strlen(cl)];
|
---|
| 1489 | z = 0;
|
---|
| 1490 | do {
|
---|
| 1491 | for (x = z; li->list[x] &&
|
---|
| 1492 | strlen(cl) + strlen(li->list[x]) < 999; x++) {
|
---|
| 1493 | strcat(cl, " ");
|
---|
| 1494 | if (needs_quoting(li->list[x]))
|
---|
| 1495 | strcat(cl, "\"");
|
---|
| 1496 | strcat(cl, li->list[x]);
|
---|
| 1497 | if (needs_quoting(li->list[x]))
|
---|
| 1498 | strcat(cl, "\"");
|
---|
| 1499 | }
|
---|
| 1500 | z = x;
|
---|
| 1501 | runemf2(SEPARATE | WINDOWED |
|
---|
| 1502 | ((fArcStuffVisible) ? 0 : (BACKGROUND | MINIMIZED)) |
|
---|
| 1503 | WAIT, hwnd, NullStr, NULL, "%s", cl);
|
---|
| 1504 | *endofit = 0;
|
---|
| 1505 | } while (li->list[x]);
|
---|
| 1506 | PostMsg(dcd->hwndCnr, UM_RESCAN, MPFROMSHORT(1), MPVOID);
|
---|
| 1507 | Broadcast(WinQueryAnchorBlock(hwnd),
|
---|
| 1508 | hwndMain,
|
---|
| 1509 | UM_UPDATERECORD, MPFROMP(dcd->arcname), MPVOID);
|
---|
| 1510 | }
|
---|
| 1511 | break;
|
---|
[2] | 1512 |
|
---|
[551] | 1513 | case IDM_PRINT:
|
---|
| 1514 | case IDM_VIRUSSCAN:
|
---|
| 1515 | case IDM_VIEW:
|
---|
| 1516 | case IDM_MCIPLAY:
|
---|
| 1517 | case IDM_VIEWARCHIVE:
|
---|
| 1518 | case IDM_VIEWTEXT:
|
---|
| 1519 | case IDM_VIEWBINARY:
|
---|
| 1520 | case IDM_EDIT:
|
---|
| 1521 | case IDM_EDITTEXT:
|
---|
| 1522 | case IDM_EDITBINARY:
|
---|
| 1523 | case IDM_EXEC:
|
---|
| 1524 | case IDM_EXTRACTWDIRS:
|
---|
| 1525 | case IDM_EXTRACT:
|
---|
| 1526 | {
|
---|
| 1527 | CHAR cl[1001], *endofit, *ptr;
|
---|
| 1528 | INT z;
|
---|
[2] | 1529 |
|
---|
[551] | 1530 | if ((li->type == IDM_EXTRACT && !li->info->extract) ||
|
---|
| 1531 | ((li->type == IDM_VIEW || li->type == IDM_VIEWTEXT ||
|
---|
| 1532 | li->type == IDM_VIEWBINARY || li->type == IDM_EDIT ||
|
---|
| 1533 | li->type == IDM_VIEWARCHIVE || li->type == IDM_EDITTEXT ||
|
---|
| 1534 | li->type == IDM_EDITBINARY || li->type == IDM_MCIPLAY) &&
|
---|
| 1535 | (!li->info->extract && !li->info->exwdirs)) ||
|
---|
| 1536 | (li->type != IDM_EXTRACT && li->type != IDM_EDIT &&
|
---|
| 1537 | li->type != IDM_VIEW && li->type != IDM_VIEWTEXT &&
|
---|
| 1538 | li->type != IDM_VIEWBINARY &&
|
---|
| 1539 | li->type != IDM_VIEWARCHIVE &&
|
---|
| 1540 | li->type != IDM_EDITTEXT &&
|
---|
| 1541 | li->type != IDM_EDITBINARY &&
|
---|
| 1542 | li->type != IDM_MCIPLAY && !li->info->exwdirs)) {
|
---|
| 1543 | Runtime_Error(pszSrcFile, __LINE__, "no cmd for request");
|
---|
| 1544 | break;
|
---|
| 1545 | }
|
---|
| 1546 | if (li->type == IDM_EXTRACT || li->type == IDM_EXTRACTWDIRS) {
|
---|
[2] | 1547 |
|
---|
[551] | 1548 | CHAR fullname[CCHMAXPATH * 2];
|
---|
| 1549 | CHAR **exfiles = NULL;
|
---|
| 1550 | INT numfiles = 0, numalloc = 0;
|
---|
[2] | 1551 |
|
---|
[551] | 1552 | for (x = 0; li->list[x]; x++) {
|
---|
| 1553 | sprintf(fullname, "%s%s%s",
|
---|
| 1554 | li->targetpath,
|
---|
| 1555 | (li->targetpath[strlen(li->targetpath) - 1] == '\\') ?
|
---|
| 1556 | NullStr : "\\", li->list[x]);
|
---|
| 1557 | if (IsFile(fullname) != -1) {
|
---|
| 1558 | AddToList(li->list[x], &exfiles, &numfiles, &numalloc);
|
---|
| 1559 | li->list = RemoveFromList(li->list, li->list[x]);
|
---|
| 1560 | if (!li->list)
|
---|
| 1561 | break;
|
---|
| 1562 | x--;
|
---|
| 1563 | }
|
---|
| 1564 | }
|
---|
| 1565 | if (exfiles && numfiles) {
|
---|
[2] | 1566 |
|
---|
[551] | 1567 | CHECKLIST ckl;
|
---|
| 1568 | CHAR prompt[(CCHMAXPATH * 2) + 256];
|
---|
[2] | 1569 |
|
---|
[551] | 1570 | memset(&ckl, 0, sizeof(ckl));
|
---|
| 1571 | ckl.size = sizeof(ckl);
|
---|
| 1572 | ckl.list = exfiles;
|
---|
| 1573 | ckl.prompt = prompt;
|
---|
| 1574 | ckl.cmd = li->type;
|
---|
| 1575 | sprintf(prompt,
|
---|
| 1576 | GetPString(IDS_REPLACEWARNTEXT),
|
---|
| 1577 | &"s"[numfiles == 1],
|
---|
| 1578 | li->arcname, &"s"[numfiles != 1], li->targetpath);
|
---|
| 1579 | if (!WinDlgBox(HWND_DESKTOP, hwnd, CheckListProc,
|
---|
| 1580 | FM3ModHandle, CHECK_FRAME, MPFROMP(&ckl))) {
|
---|
| 1581 | if (ckl.list)
|
---|
| 1582 | FreeList(ckl.list);
|
---|
| 1583 | break;
|
---|
| 1584 | }
|
---|
| 1585 | else if (ckl.list)
|
---|
| 1586 | li->list = CombineLists(li->list, ckl.list);
|
---|
| 1587 | }
|
---|
| 1588 | }
|
---|
| 1589 | if (!li->list || !li->list[0])
|
---|
| 1590 | break;
|
---|
| 1591 | sprintf(cl, "%s %s%s%s", (li->type == IDM_EXTRACT ||
|
---|
| 1592 | ((li->type == IDM_VIEW
|
---|
| 1593 | || li->type == IDM_VIEWTEXT
|
---|
| 1594 | || li->type == IDM_VIEWBINARY
|
---|
| 1595 | || li->type == IDM_VIEWARCHIVE
|
---|
| 1596 | || li->type == IDM_PRINT
|
---|
| 1597 | || li->type == IDM_EDIT
|
---|
| 1598 | || li->type == IDM_EDITTEXT
|
---|
| 1599 | || li->type == IDM_EDITBINARY
|
---|
| 1600 | && li->type == IDM_MCIPLAY)
|
---|
| 1601 | && !li->info->exwdirs)) ? li->info->
|
---|
| 1602 | extract : li->info->exwdirs,
|
---|
| 1603 | (needs_quoting(li->arcname)) ? "\"" : NullStr,
|
---|
| 1604 | li->arcname,
|
---|
| 1605 | (needs_quoting(li->arcname)) ? "\"" : NullStr);
|
---|
| 1606 | endofit = &cl[strlen(cl)];
|
---|
| 1607 | z = 0;
|
---|
| 1608 | do {
|
---|
| 1609 | for (x = z; li->list[x] &&
|
---|
| 1610 | strlen(cl) + strlen(li->list[x]) < 999; x++) {
|
---|
| 1611 | strcat(cl, " ");
|
---|
| 1612 | if (needs_quoting(li->list[x]))
|
---|
| 1613 | strcat(cl, "\"");
|
---|
| 1614 | strcat(cl, li->list[x]);
|
---|
| 1615 | if (needs_quoting(li->list[x]))
|
---|
| 1616 | strcat(cl, "\"");
|
---|
| 1617 | ptr = li->list[x];
|
---|
| 1618 | while (*ptr) {
|
---|
| 1619 | if (*ptr == '/')
|
---|
| 1620 | *ptr = '\\';
|
---|
| 1621 | ptr++;
|
---|
| 1622 | }
|
---|
| 1623 | }
|
---|
| 1624 | z = x;
|
---|
| 1625 | runemf2(SEPARATE | WINDOWED |
|
---|
| 1626 | (fArcStuffVisible ? 0 : (BACKGROUND | MINIMIZED)) |
|
---|
| 1627 | WAIT, hwnd, li->targetpath, NULL, "%s", cl);
|
---|
| 1628 | *endofit = 0;
|
---|
| 1629 | } while (li->list[x]);
|
---|
| 1630 | if (li->type == IDM_EXTRACT || li->type == IDM_EXTRACTWDIRS) {
|
---|
| 1631 | /* update windows */
|
---|
| 1632 | for (x = 0; li->list[x]; x++) {
|
---|
[2] | 1633 |
|
---|
[551] | 1634 | CHAR *temp, *p;
|
---|
[2] | 1635 |
|
---|
[551] | 1636 | temp = li->list[x];
|
---|
| 1637 | p = temp;
|
---|
| 1638 | while (*p) {
|
---|
| 1639 | if (*p == '/')
|
---|
| 1640 | *p = '\\';
|
---|
| 1641 | p++;
|
---|
| 1642 | }
|
---|
| 1643 | p =
|
---|
| 1644 | xmalloc(strlen(temp) + strlen(li->targetpath) + 2,
|
---|
| 1645 | pszSrcFile, __LINE__);
|
---|
| 1646 | if (p) {
|
---|
| 1647 | strcpy(p, li->targetpath);
|
---|
| 1648 | if (p[strlen(p) - 1] != '\\')
|
---|
| 1649 | strcat(p, "\\");
|
---|
| 1650 | strcat(p, temp);
|
---|
| 1651 | li->list[x] = p;
|
---|
| 1652 | free(temp);
|
---|
| 1653 | }
|
---|
| 1654 | }
|
---|
| 1655 | if (fFolderAfterExtract) {
|
---|
[2] | 1656 |
|
---|
[551] | 1657 | CHAR objectpath[CCHMAXPATH], *p;
|
---|
| 1658 | APIRET rc;
|
---|
[2] | 1659 |
|
---|
[551] | 1660 | GetDesktopName(objectpath, sizeof(objectpath));
|
---|
| 1661 | rc = WinDlgBox(HWND_DESKTOP, dcd->hwndParent, ObjCnrDlgProc,
|
---|
| 1662 | FM3ModHandle, OBJCNR_FRAME,
|
---|
| 1663 | MPFROMP(objectpath));
|
---|
| 1664 | if (rc) {
|
---|
| 1665 | if (rc > 1)
|
---|
| 1666 | strcpy(objectpath, "<WP_DESKTOP>");
|
---|
| 1667 | p = NULL;
|
---|
| 1668 | if (li->arcname) {
|
---|
| 1669 | p = strrchr(li->arcname, '\\');
|
---|
| 1670 | if (p)
|
---|
| 1671 | p++;
|
---|
| 1672 | }
|
---|
| 1673 | MakeShadows(dcd->hwndParent, li->list, 2, objectpath, p);
|
---|
| 1674 | }
|
---|
| 1675 | }
|
---|
| 1676 | Broadcast(WinQueryAnchorBlock(hwnd),
|
---|
| 1677 | hwndMain,
|
---|
| 1678 | UM_UPDATERECORDLIST, MPFROMP(li->list), MPVOID);
|
---|
| 1679 | }
|
---|
| 1680 | else if (li->type == IDM_EXEC)
|
---|
| 1681 | ExecOnList(hwnd,
|
---|
| 1682 | li->runfile,
|
---|
| 1683 | WINDOWED | SEPARATEKEEP | PROMPT,
|
---|
| 1684 | li->targetpath,
|
---|
| 1685 | NULL, GetPString(IDS_EXECARCFILETITLETEXT));
|
---|
| 1686 | else if (li->type == IDM_VIRUSSCAN)
|
---|
| 1687 | ExecOnList(hwnd, virus, PROMPT | WINDOWED | SEPARATEKEEP,
|
---|
| 1688 | li->targetpath, NULL,
|
---|
| 1689 | GetPString(IDS_VIRUSSCANARCHIVETITLETEXT));
|
---|
| 1690 | else if (li->type == IDM_VIEW || li->type == IDM_VIEWTEXT ||
|
---|
| 1691 | li->type == IDM_VIEWBINARY || li->type == IDM_EDIT ||
|
---|
| 1692 | li->type == IDM_EDITTEXT ||
|
---|
| 1693 | li->type == IDM_VIEWARCHIVE ||
|
---|
| 1694 | li->type == IDM_EDITBINARY ||
|
---|
| 1695 | li->type == IDM_MCIPLAY || li->type == IDM_PRINT) {
|
---|
[2] | 1696 |
|
---|
[551] | 1697 | CHAR *temp, *p;
|
---|
[2] | 1698 |
|
---|
[551] | 1699 | for (x = 0; li->list[x]; x++) {
|
---|
| 1700 | if (!li->info->exwdirs) {
|
---|
| 1701 | temp = li->list[x];
|
---|
| 1702 | p = strrchr(li->list[x], '\\');
|
---|
| 1703 | if (p) {
|
---|
| 1704 | p++;
|
---|
| 1705 | li->list[x] = xstrdup(p, pszSrcFile, __LINE__);
|
---|
| 1706 | if (!li->list[x])
|
---|
| 1707 | li->list[x] = temp;
|
---|
| 1708 | else {
|
---|
| 1709 | free(temp);
|
---|
| 1710 | }
|
---|
| 1711 | }
|
---|
| 1712 | }
|
---|
| 1713 | sprintf(cl, "%s%s%s", li->targetpath,
|
---|
| 1714 | (li->targetpath[strlen(li->targetpath) - 1] == '\\') ?
|
---|
| 1715 | NullStr : "\\", li->list[x]);
|
---|
| 1716 | temp = li->list[x];
|
---|
| 1717 | li->list[x] = xstrdup(cl, pszSrcFile, __LINE__);
|
---|
| 1718 | if (!li->list[x])
|
---|
| 1719 | li->list[x] = temp;
|
---|
| 1720 | else
|
---|
| 1721 | free(temp);
|
---|
| 1722 | }
|
---|
| 1723 | if (li->type == IDM_VIEW || li->type == IDM_EDIT) {
|
---|
[2] | 1724 |
|
---|
[551] | 1725 | BOOL isit = TestBinary(li->list[0]);
|
---|
[2] | 1726 |
|
---|
[551] | 1727 | if (isit) {
|
---|
| 1728 | if (li->type == IDM_VIEW)
|
---|
| 1729 | li->type = IDM_VIEWBINARY;
|
---|
| 1730 | else
|
---|
| 1731 | li->type = IDM_EDITBINARY;
|
---|
| 1732 | }
|
---|
| 1733 | else {
|
---|
| 1734 | if (li->type == IDM_VIEW)
|
---|
| 1735 | li->type = IDM_VIEWTEXT;
|
---|
| 1736 | else
|
---|
| 1737 | li->type = IDM_EDITTEXT;
|
---|
| 1738 | }
|
---|
| 1739 | }
|
---|
| 1740 | if (li->type == IDM_MCIPLAY) {
|
---|
[2] | 1741 |
|
---|
[551] | 1742 | FILE *fp;
|
---|
[2] | 1743 |
|
---|
[551] | 1744 | fp = xfopen("$FM2PLAY.$$$", "w", pszSrcFile, __LINE__);
|
---|
| 1745 | if (fp) {
|
---|
| 1746 | fprintf(fp, "%s", ";AV/2-built FM2Play listfile\n");
|
---|
| 1747 | for (x = 0; li->list[x]; x++)
|
---|
| 1748 | fprintf(fp, "%s\n", li->list[x]);
|
---|
| 1749 | fprintf(fp, ";end\n");
|
---|
| 1750 | fclose(fp);
|
---|
| 1751 | runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, NULL,
|
---|
| 1752 | NULL, "%sFM2PLAY.EXE /@$FM2PLAY.$$$",
|
---|
| 1753 | (fAddUtils) ? "UTILS\\" : NullStr);
|
---|
| 1754 | }
|
---|
| 1755 | }
|
---|
| 1756 | else if (li->type == IDM_PRINT) {
|
---|
| 1757 | strcpy(li->targetpath, printer);
|
---|
| 1758 | if (_beginthread(PrintListThread, NULL, 65536, (PVOID) li) !=
|
---|
| 1759 | -1) {
|
---|
| 1760 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 1761 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
| 1762 | li = NULL;
|
---|
| 1763 | }
|
---|
| 1764 | }
|
---|
| 1765 | else if (li->type == IDM_VIEWARCHIVE) {
|
---|
[2] | 1766 |
|
---|
[551] | 1767 | ARC_TYPE *info;
|
---|
[2] | 1768 |
|
---|
[551] | 1769 | for (x = 0; li->list[x]; x++) {
|
---|
| 1770 | if (IsFile(li->list[x]) == 1) {
|
---|
| 1771 | info = NULL; // Do not hide dups - fixme to know why?
|
---|
| 1772 | if (WinDlgBox(HWND_DESKTOP, HWND_DESKTOP,
|
---|
| 1773 | SBoxDlgProc, FM3ModHandle, ASEL_FRAME,
|
---|
| 1774 | (PVOID) & info) && info) {
|
---|
| 1775 | StartArcCnr(HWND_DESKTOP,
|
---|
| 1776 | HWND_DESKTOP, li->list[x], 4, info);
|
---|
| 1777 | }
|
---|
| 1778 | }
|
---|
| 1779 | }
|
---|
| 1780 | }
|
---|
| 1781 | else if ((li->type == IDM_VIEWTEXT && *viewer) ||
|
---|
| 1782 | (li->type == IDM_VIEWBINARY && *binview) ||
|
---|
| 1783 | (li->type == IDM_EDITTEXT && *editor) ||
|
---|
| 1784 | (li->type == IDM_EDITBINARY && *bined)) {
|
---|
| 1785 | DosSleep(100);
|
---|
| 1786 | ExecOnList(hwnd, ((li->type == IDM_VIEWTEXT) ? viewer :
|
---|
| 1787 | (li->type == IDM_VIEWBINARY) ? binview :
|
---|
| 1788 | (li->type == IDM_EDITTEXT) ? editor :
|
---|
| 1789 | bined),
|
---|
| 1790 | WINDOWED | SEPARATE, li->targetpath, li->list,
|
---|
| 1791 | NULL);
|
---|
| 1792 | }
|
---|
| 1793 | else {
|
---|
| 1794 | if (li->hwnd) {
|
---|
[2] | 1795 |
|
---|
[551] | 1796 | ULONG viewtype;
|
---|
[2] | 1797 |
|
---|
[551] | 1798 | for (x = 0; li->list[x]; x++) {
|
---|
| 1799 | if (x == 0) {
|
---|
| 1800 | if (li->type == IDM_VIEWBINARY ||
|
---|
| 1801 | li->type == IDM_EDITBINARY)
|
---|
| 1802 | viewtype = 16;
|
---|
| 1803 | else
|
---|
| 1804 | viewtype = 8;
|
---|
| 1805 | }
|
---|
| 1806 | else
|
---|
| 1807 | viewtype = 0;
|
---|
| 1808 | temp = xstrdup(li->list[x], pszSrcFile, __LINE__);
|
---|
| 1809 | if (temp) {
|
---|
| 1810 | if (!PostMsg(WinQueryWindow(li->hwnd, QW_PARENT),
|
---|
| 1811 | UM_LOADFILE,
|
---|
| 1812 | MPFROMLONG(4L +
|
---|
| 1813 | (li->type == IDM_VIEWTEXT ||
|
---|
| 1814 | li->type == IDM_VIEWBINARY) +
|
---|
| 1815 | viewtype), MPFROMP(temp)))
|
---|
| 1816 | free(temp);
|
---|
| 1817 | }
|
---|
| 1818 | }
|
---|
| 1819 | }
|
---|
| 1820 | }
|
---|
| 1821 | }
|
---|
| 1822 | }
|
---|
| 1823 | break;
|
---|
[2] | 1824 |
|
---|
[551] | 1825 | case IDM_FIND:
|
---|
| 1826 | {
|
---|
| 1827 | INT numfiles = 0, numalloced = 0;
|
---|
| 1828 | CHAR **list2 = NULL, fullname[CCHMAXPATH * 2], *p;
|
---|
[2] | 1829 |
|
---|
[551] | 1830 | for (x = 0; li->list[x]; x++) {
|
---|
| 1831 | p = li->list[x];
|
---|
| 1832 | while (*p) {
|
---|
| 1833 | if (*p == '/')
|
---|
| 1834 | *p = '\\';
|
---|
| 1835 | p++;
|
---|
| 1836 | }
|
---|
| 1837 | sprintf(fullname, "%s%s%s", dcd->directory,
|
---|
| 1838 | (dcd->directory[strlen(dcd->directory) - 1] == '\\') ?
|
---|
| 1839 | NullStr : "\\", li->list[x]);
|
---|
| 1840 | if (IsFile(fullname) != -1)
|
---|
| 1841 | if (AddToList(fullname, &list2, &numfiles, &numalloced))
|
---|
| 1842 | break;
|
---|
| 1843 | if (strchr(li->list[x], '\\')) {
|
---|
| 1844 | p = strrchr(li->list[x], '\\');
|
---|
| 1845 | if (p) {
|
---|
| 1846 | p++;
|
---|
| 1847 | if (*p) {
|
---|
| 1848 | sprintf(fullname, "%s%s%s", dcd->directory,
|
---|
| 1849 | (dcd->directory[strlen(dcd->directory) - 1] ==
|
---|
| 1850 | '\\') ? NullStr : "\\", p);
|
---|
| 1851 | if (IsFile(fullname) != -1)
|
---|
| 1852 | if (AddToList(fullname, &list2, &numfiles, &numalloced))
|
---|
| 1853 | break;
|
---|
| 1854 | }
|
---|
| 1855 | }
|
---|
| 1856 | }
|
---|
| 1857 | }
|
---|
| 1858 | if (!numfiles || !list2)
|
---|
| 1859 | Runtime_Error(pszSrcFile, __LINE__, "no files or list");
|
---|
| 1860 | else {
|
---|
| 1861 | WinSendMsg(dcd->hwndCnr, WM_COMMAND,
|
---|
| 1862 | MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
|
---|
| 1863 | DosSleep(128L);
|
---|
| 1864 | if (Collector) {
|
---|
| 1865 | if (!PostMsg(Collector, WM_COMMAND,
|
---|
| 1866 | MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list2)))
|
---|
| 1867 | FreeList(list2);
|
---|
| 1868 | }
|
---|
| 1869 | else
|
---|
| 1870 | FreeList(list2);
|
---|
| 1871 | }
|
---|
| 1872 | }
|
---|
| 1873 | break;
|
---|
| 1874 | }
|
---|
[2] | 1875 | }
|
---|
[551] | 1876 | FreeListInfo(li);
|
---|
| 1877 | }
|
---|
| 1878 | return 0;
|
---|
[2] | 1879 |
|
---|
[551] | 1880 | case WM_CLOSE:
|
---|
| 1881 | WinDestroyWindow(hwnd);
|
---|
| 1882 | break;
|
---|
[2] | 1883 |
|
---|
[551] | 1884 | case WM_DESTROY:
|
---|
| 1885 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1886 | if (dcd) {
|
---|
| 1887 | if (*dcd->workdir) {
|
---|
| 1888 | DosSleep(33L);
|
---|
| 1889 | wipeallf("%s\\*", dcd->workdir);
|
---|
| 1890 | if (rmdir(dcd->workdir)) {
|
---|
| 1891 | DosSleep(256L);
|
---|
| 1892 | wipeallf("%s\\*", dcd->workdir);
|
---|
| 1893 | rmdir(dcd->workdir);
|
---|
| 1894 | }
|
---|
[2] | 1895 | }
|
---|
[551] | 1896 | FreeList(dcd->lastselection);
|
---|
| 1897 | WinSendMsg(dcd->hwndCnr, UM_CLOSE, MPVOID, MPVOID);
|
---|
| 1898 | free(dcd);
|
---|
| 1899 | WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
|
---|
| 1900 | }
|
---|
| 1901 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
| 1902 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
| 1903 | break;
|
---|
| 1904 | } // switch
|
---|
| 1905 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1906 | }
|
---|
| 1907 |
|
---|
[551] | 1908 | static MRESULT EXPENTRY ArcCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 1909 | MPARAM mp2)
|
---|
[172] | 1910 | {
|
---|
[551] | 1911 | DIRCNRDATA *dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[2] | 1912 |
|
---|
[551] | 1913 | switch (msg) {
|
---|
| 1914 | case DM_PRINTOBJECT:
|
---|
| 1915 | case DM_DISCARDOBJECT:
|
---|
| 1916 | if (dcd)
|
---|
| 1917 | return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
|
---|
| 1918 | else
|
---|
| 1919 | return MRFROMLONG(DRR_TARGET);
|
---|
[2] | 1920 |
|
---|
[551] | 1921 | case WM_CHAR:
|
---|
| 1922 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
| 1923 | if (SHORT1FROMMP(mp1) & KC_KEYUP)
|
---|
| 1924 | return (MRESULT) TRUE;
|
---|
| 1925 | if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
|
---|
| 1926 | switch (SHORT2FROMMP(mp2)) {
|
---|
| 1927 | case VK_DELETE:
|
---|
| 1928 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
|
---|
| 1929 | break;
|
---|
[2] | 1930 | }
|
---|
[551] | 1931 | }
|
---|
| 1932 | if (shiftstate || fNoSearch)
|
---|
| 1933 | break;
|
---|
| 1934 | if (SHORT1FROMMP(mp1) & KC_CHAR) {
|
---|
[2] | 1935 |
|
---|
[551] | 1936 | ULONG thistime, len;
|
---|
| 1937 | SEARCHSTRING srch;
|
---|
| 1938 | PCNRITEM pci;
|
---|
[2] | 1939 |
|
---|
[551] | 1940 | if (!dcd)
|
---|
| 1941 | break;
|
---|
| 1942 | switch (SHORT1FROMMP(mp2)) {
|
---|
| 1943 | case '\x1b':
|
---|
| 1944 | case '\r':
|
---|
| 1945 | case '\n':
|
---|
| 1946 | dcd->lasttime = 0;
|
---|
| 1947 | *dcd->szCommonName = 0;
|
---|
| 1948 | break;
|
---|
| 1949 | default:
|
---|
| 1950 | thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
|
---|
| 1951 | if (thistime > dcd->lasttime + 1250)
|
---|
| 1952 | *dcd->szCommonName = 0;
|
---|
| 1953 | dcd->lasttime = thistime;
|
---|
| 1954 | if (SHORT1FROMMP(mp2) == ' ' && !*dcd->szCommonName)
|
---|
| 1955 | break;
|
---|
| 1956 | KbdRetry:
|
---|
| 1957 | len = strlen(dcd->szCommonName);
|
---|
| 1958 | if (len >= CCHMAXPATH - 1) {
|
---|
| 1959 | *dcd->szCommonName = 0;
|
---|
| 1960 | len = 0;
|
---|
| 1961 | }
|
---|
| 1962 | dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
|
---|
| 1963 | dcd->szCommonName[len + 1] = 0;
|
---|
| 1964 | memset(&srch, 0, sizeof(SEARCHSTRING));
|
---|
| 1965 | srch.cb = (ULONG) sizeof(SEARCHSTRING);
|
---|
| 1966 | srch.pszSearch = dcd->szCommonName;
|
---|
| 1967 | srch.fsPrefix = TRUE;
|
---|
| 1968 | srch.fsCaseSensitive = FALSE;
|
---|
| 1969 | srch.usView = CV_ICON;
|
---|
| 1970 | pci = WinSendMsg(hwnd,
|
---|
| 1971 | CM_SEARCHSTRING,
|
---|
| 1972 | MPFROMP(&srch), MPFROMLONG(CMA_FIRST));
|
---|
| 1973 | if (pci && (INT) pci != -1) {
|
---|
[2] | 1974 |
|
---|
[551] | 1975 | USHORT attrib = CRA_CURSORED;
|
---|
[2] | 1976 |
|
---|
[551] | 1977 | /* make found item current item */
|
---|
| 1978 | if (!stricmp(pci->pszFileName, dcd->szCommonName))
|
---|
| 1979 | attrib |= CRA_SELECTED;
|
---|
| 1980 | WinSendMsg(hwnd,
|
---|
| 1981 | CM_SETRECORDEMPHASIS,
|
---|
| 1982 | MPFROMP(pci), MPFROM2SHORT(TRUE, attrib));
|
---|
| 1983 | /* make sure that record shows in viewport */
|
---|
| 1984 | ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
|
---|
| 1985 | return (MRESULT) TRUE;
|
---|
| 1986 | }
|
---|
| 1987 | else {
|
---|
| 1988 | if (SHORT1FROMMP(mp2) == ' ') {
|
---|
| 1989 | dcd->szCommonName[len] = 0;
|
---|
| 1990 | break;
|
---|
| 1991 | }
|
---|
| 1992 | *dcd->szCommonName = 0;
|
---|
| 1993 | dcd->lasttime = 0;
|
---|
| 1994 | if (len) // retry as first letter if no match
|
---|
| 1995 | goto KbdRetry;
|
---|
| 1996 | }
|
---|
| 1997 | break;
|
---|
[2] | 1998 | }
|
---|
[551] | 1999 | }
|
---|
| 2000 | break;
|
---|
[2] | 2001 |
|
---|
[551] | 2002 | case WM_MOUSEMOVE:
|
---|
| 2003 | case WM_BUTTON1UP:
|
---|
| 2004 | case WM_BUTTON2UP:
|
---|
| 2005 | case WM_BUTTON3UP:
|
---|
| 2006 | case WM_CHORD:
|
---|
| 2007 | shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
| 2008 | break;
|
---|
[2] | 2009 |
|
---|
[551] | 2010 | case WM_BUTTON1MOTIONEND:
|
---|
| 2011 | {
|
---|
| 2012 | CNRINFO cnri;
|
---|
[2] | 2013 |
|
---|
[551] | 2014 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
| 2015 | cnri.cb = sizeof(CNRINFO);
|
---|
| 2016 | if (WinSendMsg(hwnd,
|
---|
| 2017 | CM_QUERYCNRINFO,
|
---|
| 2018 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
|
---|
| 2019 | if (cnri.flWindowAttr & CV_DETAIL)
|
---|
| 2020 | PrfWriteProfileData(fmprof,
|
---|
| 2021 | appname,
|
---|
| 2022 | "ArcCnrSplitBar",
|
---|
| 2023 | (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
|
---|
[2] | 2024 | }
|
---|
[551] | 2025 | }
|
---|
| 2026 | break;
|
---|
[2] | 2027 |
|
---|
[551] | 2028 | case WM_PRESPARAMCHANGED:
|
---|
| 2029 | PresParamChanged(hwnd, "ArcCnr", mp1, mp2);
|
---|
| 2030 | break;
|
---|
[2] | 2031 |
|
---|
[551] | 2032 | case UM_UPDATERECORD:
|
---|
| 2033 | case UM_UPDATERECORDLIST:
|
---|
| 2034 | if (dcd && !IsArcThere(hwnd, dcd->arcname))
|
---|
| 2035 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2036 | return 0;
|
---|
[2] | 2037 |
|
---|
[551] | 2038 | case WM_SETFOCUS:
|
---|
| 2039 | /*
|
---|
| 2040 | * put name of our window (archive name) on status line
|
---|
| 2041 | */
|
---|
| 2042 | if (dcd && hwndStatus && mp2)
|
---|
| 2043 | WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 2044 | break;
|
---|
[2] | 2045 |
|
---|
[551] | 2046 | case UM_SETUP2:
|
---|
| 2047 | if (dcd && dcd->info) {
|
---|
| 2048 | if (dcd->info->fdpos == -1 || !dcd->info->datetype)
|
---|
| 2049 | dcd->sortFlags &= (~SORT_LWDATE);
|
---|
| 2050 | if (dcd->info->nsizepos == -1)
|
---|
| 2051 | dcd->sortFlags &= (~SORT_EASIZE);
|
---|
| 2052 | if (dcd->info->osizepos == -1)
|
---|
| 2053 | dcd->sortFlags &= (~SORT_SIZE);
|
---|
| 2054 | AdjustCnrColVis(hwnd,
|
---|
| 2055 | GetPString(IDS_OLDSIZECOLTEXT),
|
---|
| 2056 | dcd->info->osizepos != -1, FALSE);
|
---|
| 2057 | AdjustCnrColVis(hwnd,
|
---|
| 2058 | GetPString(IDS_NEWSIZECOLTEXT),
|
---|
| 2059 | dcd->info->nsizepos != -1, FALSE);
|
---|
| 2060 | // Display unsullied date/time string if type 0
|
---|
| 2061 | AdjustCnrColVis(hwnd,
|
---|
| 2062 | GetPString(IDS_DATETIMECOLTEXT),
|
---|
| 2063 | dcd->info->fdpos != -1 && !dcd->info->datetype, FALSE);
|
---|
| 2064 | // Display parsed date/time columns if type specified
|
---|
| 2065 | AdjustCnrColVis(hwnd,
|
---|
| 2066 | GetPString(IDS_TIMECOLTEXT),
|
---|
| 2067 | dcd->info->fdpos != -1 && dcd->info->datetype, FALSE);
|
---|
| 2068 | AdjustCnrColVis(hwnd,
|
---|
| 2069 | GetPString(IDS_DATECOLTEXT),
|
---|
| 2070 | dcd->info->fdpos != -1 && dcd->info->datetype, FALSE);
|
---|
| 2071 | WinSendMsg(hwnd, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
|
---|
| 2072 | }
|
---|
| 2073 | return 0;
|
---|
[2] | 2074 |
|
---|
[551] | 2075 | case UM_RESCAN:
|
---|
| 2076 | if (dcd) {
|
---|
| 2077 | CNRINFO cnri;
|
---|
| 2078 | CHAR s[CCHMAXPATH * 2], tb[81], tf[81];
|
---|
| 2079 | PARCITEM pci;
|
---|
[2] | 2080 |
|
---|
[551] | 2081 | if (mp1) {
|
---|
| 2082 | PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 2083 | return 0;
|
---|
| 2084 | }
|
---|
| 2085 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
| 2086 | cnri.cb = sizeof(CNRINFO);
|
---|
| 2087 | WinSendMsg(hwnd,
|
---|
| 2088 | CM_QUERYCNRINFO,
|
---|
| 2089 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
|
---|
| 2090 | dcd->totalfiles = cnri.cRecords;
|
---|
| 2091 | commafmt(tf, sizeof(tf), dcd->selectedfiles);
|
---|
| 2092 | if (dcd->ullTotalBytes)
|
---|
| 2093 | CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
|
---|
| 2094 | else
|
---|
| 2095 | *tb = 0;
|
---|
| 2096 | sprintf(s, "%s%s%s", tf, *tb ? " / " : NullStr, tb);
|
---|
| 2097 | WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
|
---|
| 2098 | commafmt(tf, sizeof(tf), dcd->totalfiles);
|
---|
| 2099 | if (dcd->ullTotalBytes)
|
---|
| 2100 | CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, 'K');
|
---|
| 2101 | else
|
---|
| 2102 | *tb = 0;
|
---|
| 2103 | sprintf(s, "%s%s%s", tf, *tb ? " / " : NullStr, tb);
|
---|
| 2104 | WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
|
---|
| 2105 | if (hwndStatus &&
|
---|
| 2106 | dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
|
---|
| 2107 | sprintf(s, " [%s%s%s]%s%s%s %s",
|
---|
| 2108 | tf,
|
---|
[156] | 2109 | *tb ? " / " : NullStr,
|
---|
[551] | 2110 | tb,
|
---|
| 2111 | (*dcd->mask.szMask) ? " (" : NullStr,
|
---|
| 2112 | (*dcd->mask.szMask) ? dcd->mask.szMask : NullStr,
|
---|
| 2113 | (*dcd->mask.szMask) ? ")" : NullStr, dcd->arcname);
|
---|
| 2114 | WinSetWindowText(hwndStatus, s);
|
---|
| 2115 | if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
| 2116 | pci = WinSendMsg(hwnd,
|
---|
| 2117 | CM_QUERYRECORDEMPHASIS,
|
---|
| 2118 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
|
---|
| 2119 | if (pci && (INT) pci != -1) {
|
---|
| 2120 | if (fSplitStatus && hwndStatus2) {
|
---|
| 2121 | if (dcd->ullTotalBytes)
|
---|
| 2122 | CommaFmtULL(tb, sizeof(tb), pci->cbFile, ' ');
|
---|
| 2123 | else
|
---|
| 2124 | *tb = 0;
|
---|
| 2125 | sprintf(s, "%s%s%s%s",
|
---|
| 2126 | *tb ? " " : NullStr,
|
---|
| 2127 | tb, *tb ? " " : NullStr, pci->szFileName);
|
---|
| 2128 | WinSetWindowText(hwndStatus2, s);
|
---|
| 2129 | }
|
---|
| 2130 | if (fMoreButtons)
|
---|
| 2131 | WinSetWindowText(hwndName, pci->szFileName);
|
---|
| 2132 | }
|
---|
| 2133 | else {
|
---|
| 2134 | WinSetWindowText(hwndStatus2, NullStr);
|
---|
| 2135 | WinSetWindowText(hwndName, NullStr);
|
---|
| 2136 | }
|
---|
| 2137 | WinSetWindowText(hwndDate, NullStr);
|
---|
| 2138 | WinSetWindowText(hwndAttr, NullStr);
|
---|
| 2139 | }
|
---|
[2] | 2140 | }
|
---|
[551] | 2141 | if ((dcd->arcfilled &&
|
---|
| 2142 | !dcd->totalfiles) || !IsArcThere(hwnd, dcd->arcname))
|
---|
| 2143 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2144 | }
|
---|
| 2145 | return 0;
|
---|
| 2146 |
|
---|
| 2147 | case UM_SETUP:
|
---|
| 2148 | if (!dcd) {
|
---|
| 2149 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2150 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
[2] | 2151 | return 0;
|
---|
[551] | 2152 | }
|
---|
| 2153 | else {
|
---|
| 2154 | if (!dcd->hwndObject) {
|
---|
| 2155 | /*
|
---|
| 2156 | * first time through -- set things up
|
---|
| 2157 | */
|
---|
| 2158 | {
|
---|
| 2159 | CHAR *p, *pp;
|
---|
| 2160 | ULONG z, was;
|
---|
| 2161 | APIRET rc;
|
---|
[2] | 2162 |
|
---|
[551] | 2163 | rc = DosCreateDir(dcd->workdir, 0);
|
---|
| 2164 | if (rc) {
|
---|
| 2165 | if (rc == ERROR_ACCESS_DENIED) {
|
---|
| 2166 | p = strrchr(dcd->workdir, '.');
|
---|
| 2167 | if (p) {
|
---|
| 2168 | p++;
|
---|
| 2169 | pp = p;
|
---|
| 2170 | was = strtoul(p, &pp, 16);
|
---|
| 2171 | for (z = 0; z < 99; z++) {
|
---|
| 2172 | was++;
|
---|
| 2173 | sprintf(p, "%03x");
|
---|
| 2174 | rc = DosCreateDir(dcd->workdir, 0);
|
---|
| 2175 | if (!rc || rc != ERROR_ACCESS_DENIED)
|
---|
| 2176 | break;
|
---|
| 2177 | }
|
---|
| 2178 | }
|
---|
| 2179 | }
|
---|
| 2180 | if (rc)
|
---|
| 2181 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2182 | return 0;
|
---|
| 2183 | }
|
---|
| 2184 | }
|
---|
| 2185 | RestorePresParams(hwnd, "ArcCnr");
|
---|
| 2186 | dcd->mask.fNoAttribs = TRUE;
|
---|
| 2187 | dcd->mask.fNoDirs = TRUE;
|
---|
| 2188 | *dcd->mask.prompt = 0;
|
---|
| 2189 | {
|
---|
| 2190 | PFIELDINFO pfi, pfiLastLeftCol;
|
---|
| 2191 | ULONG numcols = CON_COLS;
|
---|
| 2192 | CNRINFO cnri;
|
---|
| 2193 | ULONG size;
|
---|
[2] | 2194 |
|
---|
[551] | 2195 | pfi = WinSendMsg(hwnd,
|
---|
| 2196 | CM_ALLOCDETAILFIELDINFO,
|
---|
| 2197 | MPFROMLONG(numcols), NULL);
|
---|
| 2198 | if (pfi) {
|
---|
[2] | 2199 |
|
---|
[551] | 2200 | PFIELDINFO pfiFirst;
|
---|
| 2201 | FIELDINFOINSERT fii;
|
---|
[2] | 2202 |
|
---|
[551] | 2203 | pfiFirst = pfi;
|
---|
| 2204 | pfi->flData = CFA_STRING | CFA_LEFT | CFA_FIREADONLY;
|
---|
| 2205 | pfi->flTitle = CFA_CENTER;
|
---|
| 2206 | pfi->pTitleData = GetPString(IDS_FILENAMECOLTEXT);
|
---|
| 2207 | pfi->offStruct = FIELDOFFSET(ARCITEM, pszFileName);
|
---|
| 2208 | pfiLastLeftCol = pfi;
|
---|
| 2209 | pfi = pfi->pNextFieldInfo;
|
---|
| 2210 | pfi->flData =
|
---|
| 2211 | CFA_ULONG | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
|
---|
| 2212 | pfi->flTitle = CFA_CENTER;
|
---|
| 2213 | pfi->pTitleData = GetPString(IDS_OLDSIZECOLTEXT);
|
---|
| 2214 | pfi->offStruct = FIELDOFFSET(ARCITEM, cbFile);
|
---|
| 2215 | pfi = pfi->pNextFieldInfo;
|
---|
| 2216 | pfi->flData =
|
---|
| 2217 | CFA_ULONG | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
|
---|
| 2218 | pfi->flTitle = CFA_CENTER;
|
---|
| 2219 | pfi->pTitleData = GetPString(IDS_NEWSIZECOLTEXT);
|
---|
| 2220 | pfi->offStruct = FIELDOFFSET(ARCITEM, cbComp);
|
---|
| 2221 | pfi = pfi->pNextFieldInfo;
|
---|
| 2222 | pfi->flData =
|
---|
| 2223 | CFA_STRING | CFA_CENTER | CFA_SEPARATOR | CFA_FIREADONLY;
|
---|
| 2224 | pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
|
---|
| 2225 | pfi->pTitleData = GetPString(IDS_DATETIMECOLTEXT);
|
---|
| 2226 | pfi->offStruct = FIELDOFFSET(ARCITEM, pszDate);
|
---|
| 2227 | pfi = pfi->pNextFieldInfo;
|
---|
| 2228 | pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
|
---|
| 2229 | pfi->flTitle = CFA_CENTER;
|
---|
| 2230 | pfi->pTitleData = GetPString(IDS_DATECOLTEXT);
|
---|
| 2231 | pfi->offStruct = FIELDOFFSET(ARCITEM, date);
|
---|
| 2232 | pfi = pfi->pNextFieldInfo;
|
---|
| 2233 | pfi->flData = CFA_TIME | CFA_RIGHT | CFA_FIREADONLY;
|
---|
| 2234 | pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
|
---|
| 2235 | pfi->pTitleData = GetPString(IDS_TIMECOLTEXT);
|
---|
| 2236 | pfi->offStruct = FIELDOFFSET(ARCITEM, time);
|
---|
| 2237 | memset(&fii, 0, sizeof(FIELDINFOINSERT));
|
---|
| 2238 | fii.cb = sizeof(FIELDINFOINSERT);
|
---|
| 2239 | fii.pFieldInfoOrder = (PFIELDINFO) CMA_FIRST;
|
---|
| 2240 | fii.cFieldInfoInsert = (SHORT) numcols;
|
---|
| 2241 | fii.fInvalidateFieldInfo = TRUE;
|
---|
| 2242 | WinSendMsg(hwnd,
|
---|
| 2243 | CM_INSERTDETAILFIELDINFO,
|
---|
| 2244 | MPFROMP(pfiFirst), MPFROMP(&fii));
|
---|
| 2245 | PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
|
---|
[2] | 2246 |
|
---|
[551] | 2247 | memset(&cnri, 0, sizeof(cnri));
|
---|
| 2248 | cnri.cb = sizeof(CNRINFO);
|
---|
| 2249 | cnri.pFieldInfoLast = pfiLastLeftCol;
|
---|
| 2250 | cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET + 32;
|
---|
[2] | 2251 |
|
---|
[551] | 2252 | size = sizeof(LONG);
|
---|
| 2253 | PrfQueryProfileData(fmprof, appname, "ArcCnrSplitBar",
|
---|
| 2254 | &cnri.xVertSplitbar, &size);
|
---|
| 2255 | if (cnri.xVertSplitbar <= 0)
|
---|
| 2256 | cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET + 32;
|
---|
[2] | 2257 |
|
---|
[551] | 2258 | cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT | CV_NAME));
|
---|
| 2259 | cnri.flWindowAttr |= (CV_DETAIL | CA_DETAILSVIEWTITLES | CV_FLOW);
|
---|
| 2260 | cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH |
|
---|
| 2261 | CA_MIXEDTARGETEMPH));
|
---|
| 2262 | cnri.pSortRecord = (PVOID) ArcSort;
|
---|
| 2263 | WinSendMsg(hwnd,
|
---|
| 2264 | CM_SETCNRINFO,
|
---|
| 2265 | MPFROMP(&cnri),
|
---|
| 2266 | MPFROMLONG(CMA_PFIELDINFOLAST |
|
---|
| 2267 | CMA_XVERTSPLITBAR |
|
---|
| 2268 | CMA_PSORTRECORD | CMA_FLWINDOWATTR));
|
---|
| 2269 | }
|
---|
| 2270 | }
|
---|
| 2271 | WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(ArcSort), MPFROMP(dcd));
|
---|
| 2272 | if (_beginthread(MakeObjWin, NULL, 245760, (PVOID) dcd) == -1) {
|
---|
| 2273 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 2274 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
| 2275 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2276 | return 0;
|
---|
| 2277 | }
|
---|
| 2278 | else
|
---|
| 2279 | DosSleep(1L);
|
---|
| 2280 | SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 2281 | DIR_FILTER), &dcd->mask, TRUE);
|
---|
| 2282 | SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 2283 | DIR_SORT), dcd->sortFlags, TRUE);
|
---|
| 2284 | DefArcSortFlags = dcd->sortFlags; // Remember for new windows
|
---|
[2] | 2285 | }
|
---|
[551] | 2286 | }
|
---|
| 2287 | return 0;
|
---|
[2] | 2288 |
|
---|
[551] | 2289 | case UM_SETDIR:
|
---|
| 2290 | if (dcd) {
|
---|
[2] | 2291 |
|
---|
[551] | 2292 | CHAR s[CCHMAXPATH], *p;
|
---|
| 2293 | ULONG ret = 0;
|
---|
[2] | 2294 |
|
---|
[551] | 2295 | WinQueryDlgItemText(dcd->hwndClient, ARC_EXTRACTDIR, CCHMAXPATH, s);
|
---|
| 2296 | bstrip(s);
|
---|
| 2297 | MakeFullName(s);
|
---|
| 2298 | if (*s) {
|
---|
| 2299 | while ((p = strchr(s, '/')) != NULL)
|
---|
| 2300 | *p = '\\';
|
---|
| 2301 | while (strlen(s) > 3 && s[strlen(s) - 1] == '\\')
|
---|
| 2302 | s[strlen(s) - 1] = 0;
|
---|
| 2303 | if (stricmp(s, dcd->directory)) {
|
---|
| 2304 | if (IsFullName(s)) {
|
---|
| 2305 | if (driveflags[toupper(*s) - 'A'] &
|
---|
| 2306 | (DRIVE_NOTWRITEABLE | DRIVE_IGNORE | DRIVE_INVALID)) {
|
---|
| 2307 | Runtime_Error(pszSrcFile, __LINE__, "drive %s bad", s);
|
---|
| 2308 | WinSetDlgItemText(dcd->hwndClient,
|
---|
| 2309 | ARC_EXTRACTDIR, dcd->directory);
|
---|
| 2310 | return 0;
|
---|
| 2311 | }
|
---|
| 2312 | }
|
---|
| 2313 | if (!SetDir(dcd->hwndParent, hwnd, s, 0)) {
|
---|
| 2314 | if (stricmp(dcd->directory, s)) {
|
---|
| 2315 | DosEnterCritSec();
|
---|
| 2316 | strcpy(lastextractpath, s);
|
---|
| 2317 | DosExitCritSec();
|
---|
| 2318 | }
|
---|
| 2319 | strcpy(dcd->directory, s);
|
---|
| 2320 | if ((!isalpha(*s) || s[1] != ':') && *s != '.')
|
---|
| 2321 | saymsg(MB_ENTER | MB_ICONASTERISK,
|
---|
| 2322 | hwnd,
|
---|
| 2323 | GetPString(IDS_WARNINGTEXT),
|
---|
| 2324 | GetPString(IDS_SPECIFYDRIVETEXT));
|
---|
| 2325 | }
|
---|
| 2326 | else
|
---|
| 2327 | ret = 1;
|
---|
| 2328 | }
|
---|
[2] | 2329 | }
|
---|
[551] | 2330 | WinSetDlgItemText(dcd->hwndClient, ARC_EXTRACTDIR, dcd->directory);
|
---|
| 2331 | return (MRESULT) ret;
|
---|
| 2332 | }
|
---|
| 2333 | return 0;
|
---|
| 2334 |
|
---|
| 2335 | case UM_ENTER:
|
---|
| 2336 | if (WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID))
|
---|
[2] | 2337 | return 0;
|
---|
[551] | 2338 | SetShiftState();
|
---|
| 2339 | if (dcd && (CHAR *) mp1) {
|
---|
[2] | 2340 |
|
---|
[551] | 2341 | SWP swp;
|
---|
| 2342 | CHAR *filename = mp1;
|
---|
[2] | 2343 |
|
---|
[551] | 2344 | if (IsFile(filename) != 1)
|
---|
| 2345 | return 0;
|
---|
| 2346 | WinQueryWindowPos(dcd->hwndFrame, &swp);
|
---|
| 2347 | DefaultViewKeys(hwnd, dcd->hwndFrame, dcd->hwndParent, &swp, filename);
|
---|
| 2348 | if (fUnHilite)
|
---|
| 2349 | UnHilite(hwnd, FALSE, &dcd->lastselection);
|
---|
| 2350 | }
|
---|
| 2351 | return 0;
|
---|
[2] | 2352 |
|
---|
[551] | 2353 | case WM_MENUEND:
|
---|
| 2354 | if (dcd) {
|
---|
[2] | 2355 |
|
---|
[551] | 2356 | HWND hwndMenu = (HWND) mp2;
|
---|
[2] | 2357 |
|
---|
[551] | 2358 | if (hwndMenu == ArcCnrMenu || hwndMenu == ArcMenu) {
|
---|
| 2359 | MarkAll(hwnd, TRUE, FALSE, TRUE);
|
---|
| 2360 | if (dcd->cnremphasized) {
|
---|
| 2361 | WinSendMsg(hwnd,
|
---|
| 2362 | CM_SETRECORDEMPHASIS,
|
---|
| 2363 | MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
|
---|
| 2364 | dcd->cnremphasized = FALSE;
|
---|
| 2365 | }
|
---|
[2] | 2366 | }
|
---|
[551] | 2367 | }
|
---|
| 2368 | break;
|
---|
[2] | 2369 |
|
---|
[551] | 2370 | case MM_PORTHOLEINIT:
|
---|
| 2371 | if (dcd) {
|
---|
| 2372 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2373 | case 0:
|
---|
| 2374 | case 1:
|
---|
| 2375 | {
|
---|
| 2376 | ULONG wmsg;
|
---|
[2] | 2377 |
|
---|
[551] | 2378 | wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
|
---|
| 2379 | PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
|
---|
| 2380 | wmsg, MPVOID, MPVOID), mp1, mp2);
|
---|
| 2381 | }
|
---|
| 2382 | break;
|
---|
[2] | 2383 | }
|
---|
[551] | 2384 | }
|
---|
| 2385 | break;
|
---|
[2] | 2386 |
|
---|
[551] | 2387 | case UM_INITMENU:
|
---|
| 2388 | case WM_INITMENU:
|
---|
| 2389 | if (dcd) {
|
---|
| 2390 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2391 | case IDM_FILESMENU:
|
---|
| 2392 | if (dcd->info) {
|
---|
| 2393 | WinEnableMenuItem((HWND) mp2,
|
---|
| 2394 | IDM_DELETE, dcd->info->delete != NULL);
|
---|
| 2395 | WinEnableMenuItem((HWND) mp2, IDM_TEST, dcd->info->test != NULL);
|
---|
| 2396 | WinEnableMenuItem((HWND) mp2,
|
---|
| 2397 | IDM_EXTRACT, dcd->info->extract != NULL);
|
---|
| 2398 | WinEnableMenuItem((HWND) mp2,
|
---|
| 2399 | IDM_EXTRACTWDIRS, dcd->info->exwdirs != NULL);
|
---|
| 2400 | WinEnableMenuItem((HWND) mp2,
|
---|
| 2401 | IDM_ARCEXTRACTWDIRS, dcd->info->exwdirs != NULL);
|
---|
| 2402 | WinEnableMenuItem((HWND) mp2,
|
---|
| 2403 | IDM_ARCEXTRACTWDIRSEXIT,
|
---|
| 2404 | dcd->info->exwdirs != NULL);
|
---|
| 2405 | }
|
---|
| 2406 | break;
|
---|
[2] | 2407 |
|
---|
[551] | 2408 | case IDM_VIEWSMENU:
|
---|
| 2409 | WinCheckMenuItem((HWND) mp2,
|
---|
| 2410 | IDM_MINIICONS, ((dcd->flWindowAttr & CV_MINI) != 0));
|
---|
| 2411 | WinEnableMenuItem((HWND) mp2,
|
---|
| 2412 | IDM_RESELECT, (dcd->lastselection != NULL));
|
---|
| 2413 | break;
|
---|
[2] | 2414 |
|
---|
[551] | 2415 | case IDM_COMMANDSMENU:
|
---|
| 2416 | SetupCommandMenu((HWND) mp2, hwnd);
|
---|
| 2417 | break;
|
---|
[2] | 2418 |
|
---|
[551] | 2419 | case IDM_SORTSUBMENU:
|
---|
| 2420 | SetSortChecks((HWND) mp2, dcd->sortFlags);
|
---|
| 2421 | break;
|
---|
[2] | 2422 |
|
---|
[551] | 2423 | case IDM_WINDOWSMENU:
|
---|
| 2424 | /*
|
---|
| 2425 | * add switchlist entries to end of pulldown menu
|
---|
| 2426 | */
|
---|
| 2427 | SetupWinList((HWND) mp2,
|
---|
| 2428 | (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
|
---|
| 2429 | break;
|
---|
[2] | 2430 | }
|
---|
[551] | 2431 | dcd->hwndLastMenu = (HWND) mp2;
|
---|
| 2432 | }
|
---|
| 2433 | if (msg == WM_INITMENU)
|
---|
| 2434 | break;
|
---|
| 2435 | return 0;
|
---|
[2] | 2436 |
|
---|
[551] | 2437 | case UM_LOADFILE:
|
---|
| 2438 | if (dcd && mp2) {
|
---|
[2] | 2439 |
|
---|
[551] | 2440 | HWND ret;
|
---|
[2] | 2441 |
|
---|
[551] | 2442 | ret = StartMLEEditor(dcd->hwndParent,
|
---|
| 2443 | (INT) mp1, (CHAR *) mp2, dcd->hwndFrame);
|
---|
| 2444 | free((CHAR *) mp2);
|
---|
| 2445 | return MRFROMLONG(ret);
|
---|
| 2446 | }
|
---|
| 2447 | return 0;
|
---|
| 2448 |
|
---|
| 2449 | case UM_COMMAND:
|
---|
| 2450 | if (mp1) {
|
---|
| 2451 | if (dcd) {
|
---|
| 2452 | if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
|
---|
| 2453 | Runtime_Error(pszSrcFile, __LINE__, "post");
|
---|
| 2454 | FreeListInfo((LISTINFO *) mp1);
|
---|
| 2455 | }
|
---|
| 2456 | else
|
---|
| 2457 | return (MRESULT) TRUE;
|
---|
[2] | 2458 | }
|
---|
[551] | 2459 | else
|
---|
| 2460 | FreeListInfo((LISTINFO *) mp1);
|
---|
| 2461 | }
|
---|
| 2462 | return 0;
|
---|
[2] | 2463 |
|
---|
[551] | 2464 | case UM_OPENWINDOWFORME:
|
---|
| 2465 | if (dcd) {
|
---|
| 2466 | if (mp1 && !IsFile((CHAR *) mp1)) {
|
---|
| 2467 | OpenDirCnr((HWND) 0, hwndMain, dcd->hwndFrame, FALSE, (char *)mp1);
|
---|
[2] | 2468 | }
|
---|
[551] | 2469 | else if (mp1 && IsFile(mp1) == 1) {
|
---|
| 2470 | StartArcCnr(HWND_DESKTOP,
|
---|
| 2471 | dcd->hwndFrame, (CHAR *) mp1, 4, (ARC_TYPE *) mp2);
|
---|
| 2472 | }
|
---|
| 2473 | }
|
---|
| 2474 | return 0;
|
---|
[2] | 2475 |
|
---|
[551] | 2476 | case WM_COMMAND:
|
---|
| 2477 | DosError(FERR_DISABLEHARDERR);
|
---|
| 2478 | if (dcd) {
|
---|
| 2479 | if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
|
---|
| 2480 | return 0;
|
---|
| 2481 | if (WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID))
|
---|
| 2482 | return 0;
|
---|
| 2483 | if (!IsArcThere(hwnd, dcd->arcname)) {
|
---|
| 2484 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2485 | return 0;
|
---|
[2] | 2486 | }
|
---|
[551] | 2487 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2488 | case IDM_TREEVIEW:
|
---|
[2] | 2489 |
|
---|
[551] | 2490 | break;
|
---|
[2] | 2491 |
|
---|
[551] | 2492 | case IDM_CONTEXTMENU:
|
---|
| 2493 | {
|
---|
| 2494 | PCNRITEM pci;
|
---|
[2] | 2495 |
|
---|
[551] | 2496 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
| 2497 | PostMsg(hwnd,
|
---|
| 2498 | WM_CONTROL,
|
---|
| 2499 | MPFROM2SHORT(ARC_CNR, CN_CONTEXTMENU), MPFROMP(pci));
|
---|
| 2500 | }
|
---|
| 2501 | break;
|
---|
[2] | 2502 |
|
---|
[551] | 2503 | case IDM_NEXTWINDOW:
|
---|
| 2504 | case IDM_PREVWINDOW:
|
---|
| 2505 | {
|
---|
| 2506 | HWND hwndActive;
|
---|
[2] | 2507 |
|
---|
[551] | 2508 | hwndActive = WinQueryFocus(HWND_DESKTOP);
|
---|
| 2509 | WinSetFocus(HWND_DESKTOP,
|
---|
| 2510 | ((hwndActive == hwnd) ?
|
---|
| 2511 | WinWindowFromID(dcd->hwndClient, ARC_EXTRACTDIR) :
|
---|
| 2512 | hwnd));
|
---|
| 2513 | }
|
---|
| 2514 | break;
|
---|
[2] | 2515 |
|
---|
[551] | 2516 | case IDM_FOLDERAFTEREXTRACT:
|
---|
| 2517 | fFolderAfterExtract = (fFolderAfterExtract) ? FALSE : TRUE;
|
---|
| 2518 | PrfWriteProfileData(fmprof, appname, "FolderAfterExtract",
|
---|
| 2519 | &fFolderAfterExtract, sizeof(BOOL));
|
---|
| 2520 | break;
|
---|
[2] | 2521 |
|
---|
[551] | 2522 | case IDM_SHOWSELECT:
|
---|
| 2523 | QuickPopup(hwnd, dcd, CheckMenu(&ArcCnrMenu, ARCCNR_POPUP),
|
---|
| 2524 | IDM_SELECTSUBMENU);
|
---|
| 2525 | break;
|
---|
[2] | 2526 |
|
---|
[551] | 2527 | case IDM_SHOWSORT:
|
---|
| 2528 | QuickPopup(hwnd, dcd, CheckMenu(&ArcCnrMenu, ARCCNR_POPUP),
|
---|
| 2529 | IDM_SORTSUBMENU);
|
---|
| 2530 | break;
|
---|
[2] | 2531 |
|
---|
[551] | 2532 | case IDM_NOTEBOOK:
|
---|
| 2533 | if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
|
---|
| 2534 | PostMsg(dcd->hwndParent, msg, mp1, mp2);
|
---|
| 2535 | else
|
---|
| 2536 | WinDlgBox(HWND_DESKTOP,
|
---|
| 2537 | hwnd,
|
---|
| 2538 | CfgDlgProc, FM3ModHandle, CFG_FRAME, (PVOID) "Archive");
|
---|
| 2539 | break;
|
---|
[2] | 2540 |
|
---|
[551] | 2541 | case IDM_RESCAN:
|
---|
| 2542 | dcd->ullTotalBytes = dcd->totalfiles =
|
---|
| 2543 | dcd->selectedfiles = dcd->selectedbytes = 0;
|
---|
| 2544 | WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0");
|
---|
| 2545 | WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k");
|
---|
| 2546 | dcd->totalfiles = FillArcCnr(dcd->hwndCnr,
|
---|
| 2547 | dcd->arcname,
|
---|
| 2548 | &dcd->info,
|
---|
| 2549 | &dcd->ullTotalBytes, &dcd->stopflag);
|
---|
| 2550 | PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 2551 | PostMsg(dcd->hwndCnr, UM_SETUP2, MPVOID, MPVOID);
|
---|
| 2552 | WinSendMsg(dcd->hwndCnr,
|
---|
| 2553 | CM_INVALIDATERECORD,
|
---|
| 2554 | MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
|
---|
| 2555 | break;
|
---|
[2] | 2556 |
|
---|
[551] | 2557 | case IDM_RESELECT:
|
---|
| 2558 | SelectList(hwnd, TRUE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
|
---|
| 2559 | break;
|
---|
[2] | 2560 |
|
---|
[551] | 2561 | case IDM_HELP:
|
---|
| 2562 | if (hwndHelp)
|
---|
| 2563 | WinSendMsg(hwndHelp,
|
---|
| 2564 | HM_DISPLAY_HELP,
|
---|
| 2565 | MPFROM2SHORT(HELP_ARCLIST, 0),
|
---|
| 2566 | MPFROMSHORT(HM_RESOURCEID));
|
---|
| 2567 | break;
|
---|
[2] | 2568 |
|
---|
[551] | 2569 | case IDM_WINDOWDLG:
|
---|
| 2570 | if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndFrame))
|
---|
| 2571 | PostMsg(dcd->hwndParent,
|
---|
| 2572 | UM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
|
---|
| 2573 | break;
|
---|
[2] | 2574 |
|
---|
[551] | 2575 | case IDM_SELECTALL:
|
---|
| 2576 | case IDM_SELECTALLFILES:
|
---|
| 2577 | case IDM_DESELECTALL:
|
---|
| 2578 | case IDM_DESELECTALLFILES:
|
---|
| 2579 | case IDM_SELECTMASK:
|
---|
| 2580 | case IDM_DESELECTMASK:
|
---|
| 2581 | case IDM_INVERT:
|
---|
| 2582 | {
|
---|
| 2583 | PARCITEM pci;
|
---|
[2] | 2584 |
|
---|
[551] | 2585 | pci = (PARCITEM) WinSendMsg(hwnd,
|
---|
| 2586 | CM_QUERYRECORDEMPHASIS,
|
---|
| 2587 | MPFROMLONG(CMA_FIRST),
|
---|
| 2588 | MPFROMSHORT(CRA_CURSORED));
|
---|
| 2589 | if ((INT) pci == -1)
|
---|
| 2590 | pci = NULL;
|
---|
| 2591 | if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
|
---|
| 2592 | if (pci) {
|
---|
| 2593 | if (!(pci->rc.flRecordAttr & CRA_SELECTED))
|
---|
| 2594 | pci->rc.flRecordAttr |= CRA_FILTERED;
|
---|
| 2595 | WinSendMsg(hwnd,
|
---|
| 2596 | CM_INVALIDATERECORD,
|
---|
| 2597 | MPFROMP(&pci),
|
---|
| 2598 | MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
|
---|
| 2599 | break;
|
---|
| 2600 | }
|
---|
| 2601 | }
|
---|
| 2602 | PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
|
---|
| 2603 | }
|
---|
| 2604 | break;
|
---|
[2] | 2605 |
|
---|
[551] | 2606 | case IDM_SORTSMARTNAME:
|
---|
| 2607 | case IDM_SORTNAME:
|
---|
| 2608 | case IDM_SORTFILENAME:
|
---|
| 2609 | case IDM_SORTSIZE:
|
---|
| 2610 | case IDM_SORTEASIZE:
|
---|
| 2611 | case IDM_SORTFIRST:
|
---|
| 2612 | case IDM_SORTLAST:
|
---|
| 2613 | case IDM_SORTLWDATE:
|
---|
| 2614 | dcd->sortFlags &= SORT_REVERSE;
|
---|
| 2615 | /* intentional fallthru */
|
---|
| 2616 | case IDM_SORTREVERSE:
|
---|
| 2617 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2618 | case IDM_SORTSMARTNAME:
|
---|
| 2619 | case IDM_SORTFILENAME:
|
---|
| 2620 | dcd->sortFlags |= SORT_FILENAME;
|
---|
| 2621 | break;
|
---|
| 2622 | case IDM_SORTSIZE:
|
---|
| 2623 | dcd->sortFlags |= SORT_SIZE;
|
---|
| 2624 | break;
|
---|
| 2625 | case IDM_SORTEASIZE:
|
---|
| 2626 | dcd->sortFlags |= SORT_EASIZE;
|
---|
| 2627 | break;
|
---|
| 2628 | case IDM_SORTFIRST:
|
---|
| 2629 | dcd->sortFlags |= SORT_FIRSTEXTENSION;
|
---|
| 2630 | break;
|
---|
| 2631 | case IDM_SORTLAST:
|
---|
| 2632 | dcd->sortFlags |= SORT_LASTEXTENSION;
|
---|
| 2633 | break;
|
---|
| 2634 | case IDM_SORTLWDATE:
|
---|
| 2635 | dcd->sortFlags |= SORT_LWDATE;
|
---|
| 2636 | break;
|
---|
| 2637 | case IDM_SORTREVERSE:
|
---|
| 2638 | if (dcd->sortFlags & SORT_REVERSE)
|
---|
| 2639 | dcd->sortFlags &= (~SORT_REVERSE);
|
---|
| 2640 | else
|
---|
| 2641 | dcd->sortFlags |= SORT_REVERSE;
|
---|
| 2642 | break;
|
---|
| 2643 | }
|
---|
| 2644 | WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(ArcSort), MPFROMP(dcd));
|
---|
| 2645 | SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 2646 | DIR_SORT), dcd->sortFlags, TRUE);
|
---|
| 2647 | DefArcSortFlags = dcd->sortFlags; // Remember for new windows
|
---|
| 2648 | break;
|
---|
[2] | 2649 |
|
---|
[551] | 2650 | case IDM_COLLECTOR:
|
---|
| 2651 | if (!Collector) {
|
---|
| 2652 | HWND hwndC;
|
---|
| 2653 | SWP swp;
|
---|
[2] | 2654 |
|
---|
[551] | 2655 | if (ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
|
---|
| 2656 | (!fExternalCollector && !strcmp(realappname, FM3Str)))
|
---|
| 2657 | GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
|
---|
| 2658 | hwndC = StartCollector((fExternalCollector ||
|
---|
| 2659 | strcmp(realappname, FM3Str)) ?
|
---|
| 2660 | HWND_DESKTOP : dcd->hwndParent, 4);
|
---|
| 2661 | if (hwndC) {
|
---|
| 2662 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
|
---|
| 2663 | (!fExternalCollector && !strcmp(realappname, FM3Str)))
|
---|
| 2664 | WinSetWindowPos(hwndC,
|
---|
| 2665 | HWND_TOP,
|
---|
| 2666 | swp.x,
|
---|
| 2667 | swp.y,
|
---|
| 2668 | swp.cx,
|
---|
| 2669 | swp.cy,
|
---|
| 2670 | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
|
---|
| 2671 | else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
| 2672 | fAutoTile && !strcmp(realappname, FM3Str)) {
|
---|
| 2673 | TileChildren(dcd->hwndParent, TRUE);
|
---|
| 2674 | }
|
---|
| 2675 | WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
|
---|
| 2676 | DosSleep(128L);
|
---|
| 2677 | }
|
---|
| 2678 | }
|
---|
| 2679 | else
|
---|
| 2680 | StartCollector(dcd->hwndParent, 4);
|
---|
| 2681 | break;
|
---|
[2] | 2682 |
|
---|
[551] | 2683 | case IDM_ARCEXTRACTEXIT:
|
---|
| 2684 | case IDM_ARCEXTRACT:
|
---|
| 2685 | if (dcd->info->extract)
|
---|
| 2686 | runemf2(SEPARATE | WINDOWED |
|
---|
| 2687 | ((fArcStuffVisible) ? 0 : (BACKGROUND | MINIMIZED)),
|
---|
| 2688 | hwnd, dcd->directory, NULL, "%s %s%s%s",
|
---|
| 2689 | dcd->info->extract,
|
---|
| 2690 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr,
|
---|
| 2691 | dcd->arcname,
|
---|
| 2692 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr);
|
---|
| 2693 | if (SHORT1FROMMP(mp1) == IDM_ARCEXTRACTEXIT)
|
---|
| 2694 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2695 | break;
|
---|
[2] | 2696 |
|
---|
[551] | 2697 | case IDM_ARCEXTRACTWDIRSEXIT:
|
---|
| 2698 | case IDM_ARCEXTRACTWDIRS:
|
---|
| 2699 | if (dcd->info->exwdirs)
|
---|
| 2700 | runemf2(SEPARATE | WINDOWED |
|
---|
| 2701 | ((fArcStuffVisible) ? 0 : (BACKGROUND | MINIMIZED)),
|
---|
| 2702 | hwnd, dcd->directory, NULL, "%s %s%s%s",
|
---|
| 2703 | dcd->info->exwdirs,
|
---|
| 2704 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr,
|
---|
| 2705 | dcd->arcname,
|
---|
| 2706 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr);
|
---|
| 2707 | if (SHORT1FROMMP(mp1) == IDM_ARCEXTRACTWDIRSEXIT)
|
---|
| 2708 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2709 | break;
|
---|
[2] | 2710 |
|
---|
[551] | 2711 | case IDM_RESORT:
|
---|
| 2712 | WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(ArcSort), MPFROMP(dcd));
|
---|
| 2713 | break;
|
---|
[2] | 2714 |
|
---|
[551] | 2715 | case IDM_FILTER:
|
---|
| 2716 | {
|
---|
| 2717 | BOOL empty = FALSE;
|
---|
| 2718 | PARCITEM pci;
|
---|
[2] | 2719 |
|
---|
[551] | 2720 | if (!*dcd->mask.szMask) {
|
---|
| 2721 | empty = TRUE;
|
---|
| 2722 | pci = (PARCITEM) CurrentRecord(hwnd);
|
---|
| 2723 | if (pci && strchr(pci->szFileName, '.'))
|
---|
| 2724 | strcpy(dcd->mask.szMask, pci->szFileName);
|
---|
| 2725 | }
|
---|
[2] | 2726 |
|
---|
[551] | 2727 | if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
|
---|
| 2728 | FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask))) {
|
---|
| 2729 | WinSendMsg(hwnd, CM_FILTER, MPFROMP(ArcFilter), MPFROMP(dcd));
|
---|
| 2730 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 2731 | }
|
---|
| 2732 | else if (empty)
|
---|
| 2733 | *dcd->mask.szMask = 0;
|
---|
| 2734 | SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 2735 | DIR_FILTER), &dcd->mask, TRUE);
|
---|
| 2736 | }
|
---|
| 2737 | break;
|
---|
[2] | 2738 |
|
---|
[551] | 2739 | case IDM_SWITCH:
|
---|
| 2740 | if (mp2) {
|
---|
| 2741 | if (stricmp(dcd->directory, (CHAR *) mp2)) {
|
---|
| 2742 | DosEnterCritSec();
|
---|
| 2743 | strcpy(lastextractpath, (CHAR *) mp2);
|
---|
| 2744 | MakeValidDir(lastextractpath);
|
---|
| 2745 | DosExitCritSec();
|
---|
| 2746 | }
|
---|
| 2747 | strcpy(dcd->directory, (CHAR *) mp2);
|
---|
| 2748 | MakeValidDir(dcd->directory);
|
---|
| 2749 | WinSetWindowText(dcd->hwndExtract, dcd->directory);
|
---|
| 2750 | }
|
---|
| 2751 | break;
|
---|
[2] | 2752 |
|
---|
[551] | 2753 | case IDM_WALKDIR:
|
---|
| 2754 | {
|
---|
| 2755 | CHAR newdir[CCHMAXPATH];
|
---|
[2] | 2756 |
|
---|
[551] | 2757 | strcpy(newdir, dcd->directory);
|
---|
| 2758 | if (!WinDlgBox(HWND_DESKTOP, dcd->hwndParent, WalkExtractDlgProc,
|
---|
| 2759 | FM3ModHandle, WALK_FRAME,
|
---|
| 2760 | MPFROMP(newdir)) || !*newdir)
|
---|
| 2761 | break;
|
---|
| 2762 | if (stricmp(newdir, dcd->directory)) {
|
---|
| 2763 | strcpy(dcd->directory, newdir);
|
---|
| 2764 | if (stricmp(lastextractpath, newdir))
|
---|
| 2765 | strcpy(lastextractpath, newdir);
|
---|
| 2766 | WinSetWindowText(dcd->hwndExtract, dcd->directory);
|
---|
| 2767 | }
|
---|
| 2768 | }
|
---|
| 2769 | break;
|
---|
[2] | 2770 |
|
---|
[551] | 2771 | case IDM_TEST:
|
---|
| 2772 | if (dcd->info->test)
|
---|
| 2773 | runemf2(SEPARATEKEEP | WINDOWED | MAXIMIZED,
|
---|
| 2774 | hwnd, NULL, NULL, "%s %s%s%s", dcd->info->test,
|
---|
| 2775 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr,
|
---|
| 2776 | dcd->arcname,
|
---|
| 2777 | (needs_quoting(dcd->arcname)) ? "\"" : NullStr);
|
---|
| 2778 | break;
|
---|
[2] | 2779 |
|
---|
[551] | 2780 | case IDM_REFRESH:
|
---|
| 2781 | case IDM_DELETE:
|
---|
| 2782 | case IDM_PRINT:
|
---|
| 2783 | case IDM_VIEW:
|
---|
| 2784 | case IDM_VIEWTEXT:
|
---|
| 2785 | case IDM_VIEWBINARY:
|
---|
| 2786 | case IDM_VIEWARCHIVE:
|
---|
| 2787 | case IDM_EDIT:
|
---|
| 2788 | case IDM_EDITTEXT:
|
---|
| 2789 | case IDM_EDITBINARY:
|
---|
| 2790 | case IDM_EXTRACT:
|
---|
| 2791 | case IDM_EXTRACTWDIRS:
|
---|
| 2792 | case IDM_FIND:
|
---|
| 2793 | case IDM_EXEC:
|
---|
| 2794 | case IDM_VIRUSSCAN:
|
---|
| 2795 | {
|
---|
| 2796 | LISTINFO *li;
|
---|
[2] | 2797 |
|
---|
[551] | 2798 | li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
|
---|
| 2799 | if (li) {
|
---|
| 2800 | li->type = SHORT1FROMMP(mp1);
|
---|
| 2801 | li->hwnd = hwnd;
|
---|
| 2802 | li->list = BuildArcList(hwnd);
|
---|
| 2803 | if (li->type == IDM_REFRESH) {
|
---|
[2] | 2804 |
|
---|
[551] | 2805 | CHAR s[CCHMAXPATH], *p;
|
---|
| 2806 | INT x, y;
|
---|
[2] | 2807 |
|
---|
[551] | 2808 | for (x = 0; li->list && li->list[x]; x++) {
|
---|
| 2809 | sprintf(s, "%s%s%s", dcd->workdir,
|
---|
| 2810 | (dcd->workdir[strlen(dcd->workdir) - 1] == '\\') ?
|
---|
| 2811 | NullStr : "\\", li->list[x]);
|
---|
| 2812 | if (IsFile(s) != 1) {
|
---|
| 2813 | free(li->list[x]);
|
---|
| 2814 | li->list[x] = NULL;
|
---|
| 2815 | for (y = x; li->list[y]; y++)
|
---|
| 2816 | li->list[y] = li->list[y + 1];
|
---|
| 2817 | li->list =
|
---|
| 2818 | xrealloc(li->list, y * sizeof(CHAR *), pszSrcFile,
|
---|
| 2819 | __LINE__);
|
---|
| 2820 | x--;
|
---|
| 2821 | }
|
---|
| 2822 | else {
|
---|
| 2823 | p = xstrdup(s, pszSrcFile, __LINE__);
|
---|
| 2824 | if (p) {
|
---|
| 2825 | free(li->list[x]);
|
---|
| 2826 | li->list[x] = p;
|
---|
| 2827 | }
|
---|
| 2828 | }
|
---|
| 2829 | } // for
|
---|
| 2830 | }
|
---|
| 2831 | strcpy(li->arcname, dcd->arcname);
|
---|
| 2832 | li->info = dcd->info;
|
---|
| 2833 | {
|
---|
| 2834 | PARCITEM pai;
|
---|
[2] | 2835 |
|
---|
[551] | 2836 | if (SHORT1FROMMP(mp1) != IDM_EXEC)
|
---|
| 2837 | pai = (PARCITEM) CurrentRecord(hwnd);
|
---|
| 2838 | else
|
---|
| 2839 | pai = (PARCITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
|
---|
| 2840 | MPFROMLONG(CMA_FIRST),
|
---|
| 2841 | MPFROMSHORT(CRA_CURSORED));
|
---|
| 2842 | if (pai && (INT) pai != -1)
|
---|
| 2843 | strcpy(li->runfile, pai->szFileName);
|
---|
| 2844 | else
|
---|
| 2845 | strcpy(li->runfile, li->list[0]);
|
---|
| 2846 | }
|
---|
| 2847 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2848 | case IDM_VIEW:
|
---|
| 2849 | case IDM_VIEWTEXT:
|
---|
| 2850 | case IDM_VIEWBINARY:
|
---|
| 2851 | case IDM_VIEWARCHIVE:
|
---|
| 2852 | case IDM_EDIT:
|
---|
| 2853 | case IDM_EDITTEXT:
|
---|
| 2854 | case IDM_EDITBINARY:
|
---|
| 2855 | case IDM_EXEC:
|
---|
| 2856 | case IDM_PRINT:
|
---|
| 2857 | case IDM_VIRUSSCAN:
|
---|
| 2858 | strcpy(li->targetpath, dcd->workdir);
|
---|
| 2859 | break;
|
---|
| 2860 | default:
|
---|
| 2861 | strcpy(li->targetpath, dcd->directory);
|
---|
| 2862 | break;
|
---|
| 2863 | }
|
---|
| 2864 | if (li->list) {
|
---|
| 2865 | if (!PostMsg(dcd->hwndObject, UM_ACTION, MPFROMP(li), MPVOID)) {
|
---|
| 2866 | Runtime_Error(pszSrcFile, __LINE__, "post");
|
---|
| 2867 | FreeListInfo(li);
|
---|
| 2868 | }
|
---|
| 2869 | else if (fUnHilite && SHORT1FROMMP(mp1) != IDM_EDIT)
|
---|
| 2870 | UnHilite(hwnd, TRUE, &dcd->lastselection);
|
---|
| 2871 | }
|
---|
| 2872 | else
|
---|
| 2873 | free(li);
|
---|
| 2874 | }
|
---|
| 2875 | }
|
---|
| 2876 | break;
|
---|
[2] | 2877 | }
|
---|
[551] | 2878 | }
|
---|
| 2879 | return 0;
|
---|
[2] | 2880 |
|
---|
[551] | 2881 | case WM_CONTROL:
|
---|
| 2882 | DosError(FERR_DISABLEHARDERR);
|
---|
| 2883 | if (dcd) {
|
---|
| 2884 | switch (SHORT2FROMMP(mp1)) {
|
---|
| 2885 | case CN_BEGINEDIT:
|
---|
| 2886 | PostMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
|
---|
| 2887 | break;
|
---|
[2] | 2888 |
|
---|
[551] | 2889 | case CN_ENDEDIT:
|
---|
| 2890 | if (!((PCNREDITDATA) mp2)->pRecord) {
|
---|
[2] | 2891 |
|
---|
[551] | 2892 | PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
|
---|
| 2893 | USHORT cmd = 0;
|
---|
[2] | 2894 |
|
---|
[551] | 2895 | if (!pfi || pfi->offStruct == FIELDOFFSET(ARCITEM, pszFileName))
|
---|
| 2896 | cmd = IDM_SORTSMARTNAME;
|
---|
| 2897 | else if (pfi->offStruct == FIELDOFFSET(ARCITEM, cbFile))
|
---|
| 2898 | cmd = IDM_SORTSIZE;
|
---|
| 2899 | else if (pfi->offStruct == FIELDOFFSET(ARCITEM, cbComp))
|
---|
| 2900 | cmd = IDM_SORTEASIZE;
|
---|
| 2901 | else if (pfi->offStruct == FIELDOFFSET(ARCITEM, date))
|
---|
| 2902 | cmd = IDM_SORTLWDATE;
|
---|
| 2903 | else if (pfi->offStruct == FIELDOFFSET(ARCITEM, time))
|
---|
| 2904 | cmd = IDM_SORTLWDATE;
|
---|
| 2905 | if (cmd)
|
---|
| 2906 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
|
---|
| 2907 | }
|
---|
| 2908 | break;
|
---|
[2] | 2909 |
|
---|
[551] | 2910 | case CN_DROPHELP:
|
---|
| 2911 | saymsg(MB_ENTER, hwnd,
|
---|
| 2912 | GetPString(IDS_DROPHELPHDRTEXT),
|
---|
| 2913 | GetPString(IDS_ARCCNRDROPHELPTEXT), dcd->arcname);
|
---|
| 2914 | return 0;
|
---|
[2] | 2915 |
|
---|
[551] | 2916 | case CN_DRAGLEAVE:
|
---|
| 2917 | if (mp2) {
|
---|
[2] | 2918 |
|
---|
[551] | 2919 | PDRAGINFO pDInfo;
|
---|
[2] | 2920 |
|
---|
[551] | 2921 | pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
|
---|
| 2922 | DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
|
---|
| 2923 | DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
|
---|
| 2924 | }
|
---|
| 2925 | return 0;
|
---|
[2] | 2926 |
|
---|
[551] | 2927 | case CN_DRAGAFTER:
|
---|
| 2928 | case CN_DRAGOVER:
|
---|
| 2929 | if (mp2) {
|
---|
[2] | 2930 |
|
---|
[551] | 2931 | PDRAGITEM pDItem; /* Pointer to DRAGITEM */
|
---|
| 2932 | PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
|
---|
| 2933 | PARCITEM pci;
|
---|
[2] | 2934 |
|
---|
[551] | 2935 | pci = (PARCITEM) ((PCNRDRAGINFO) mp2)->pRecord;
|
---|
| 2936 | if (SHORT1FROMMP(mp1) == CN_DRAGAFTER)
|
---|
| 2937 | pci = NULL;
|
---|
| 2938 | pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
|
---|
| 2939 | DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
|
---|
| 2940 | if (*dcd->arcname) {
|
---|
| 2941 | if ((driveflags[toupper(*dcd->arcname) - 'A'] &
|
---|
| 2942 | DRIVE_NOTWRITEABLE) || !dcd->info || !dcd->info->create) {
|
---|
| 2943 | DrgFreeDraginfo(pDInfo);
|
---|
| 2944 | return MRFROM2SHORT(DOR_NEVERDROP, 0);
|
---|
| 2945 | }
|
---|
| 2946 | }
|
---|
| 2947 | if (pci) {
|
---|
| 2948 | DrgFreeDraginfo(pDInfo);
|
---|
| 2949 | return MRFROM2SHORT(DOR_NODROP, 0);
|
---|
| 2950 | }
|
---|
| 2951 | pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
|
---|
| 2952 | 0); /* Index to DRAGITEM */
|
---|
| 2953 | if (DrgVerifyRMF(pDItem, /* Check valid rendering */
|
---|
| 2954 | DRM_OS2FILE, /* mechanisms and data */
|
---|
| 2955 | NULL) && !(pDItem->fsControl & DC_PREPARE)) {
|
---|
| 2956 | DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
|
---|
| 2957 | return (MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
|
---|
| 2958 | ((fCopyDefault) ? DO_COPY : DO_MOVE)));
|
---|
| 2959 | }
|
---|
| 2960 | DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
|
---|
| 2961 | }
|
---|
| 2962 | return (MRFROM2SHORT(DOR_NEVERDROP, 0)); /* Drop not valid */
|
---|
[2] | 2963 |
|
---|
[551] | 2964 | case CN_INITDRAG:
|
---|
| 2965 | if (mp2) {
|
---|
[2] | 2966 |
|
---|
[551] | 2967 | BOOL wasemphasized = FALSE;
|
---|
| 2968 | PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
|
---|
| 2969 | PARCITEM pci;
|
---|
[2] | 2970 |
|
---|
[551] | 2971 | if (pcd) {
|
---|
| 2972 | pci = (PARCITEM) pcd->pRecord;
|
---|
| 2973 | if (pci) {
|
---|
| 2974 | if (pci->rc.flRecordAttr & CRA_SELECTED)
|
---|
| 2975 | wasemphasized = TRUE;
|
---|
| 2976 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
| 2977 | fSplitStatus && hwndStatus2)
|
---|
| 2978 | WinSetWindowText(hwndStatus2, GetPString(IDS_DRAGARCMEMTEXT));
|
---|
| 2979 | if (DoFileDrag(hwnd,
|
---|
| 2980 | dcd->hwndObject,
|
---|
| 2981 | mp2, dcd->arcname, NULL, TRUE)) {
|
---|
| 2982 | if (fUnHilite && wasemphasized)
|
---|
| 2983 | UnHilite(hwnd, TRUE, &dcd->lastselection);
|
---|
| 2984 | }
|
---|
| 2985 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
| 2986 | fSplitStatus && hwndStatus2) {
|
---|
| 2987 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 2988 | }
|
---|
| 2989 | }
|
---|
| 2990 | else {
|
---|
| 2991 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
| 2992 | fSplitStatus && hwndStatus2)
|
---|
| 2993 | WinSetWindowText(hwndStatus2,
|
---|
| 2994 | GetPString(IDS_DRAGARCFILETEXT));
|
---|
| 2995 | DragOne(hwnd, dcd->hwndObject, dcd->arcname, FALSE);
|
---|
| 2996 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
| 2997 | fSplitStatus && hwndStatus2)
|
---|
| 2998 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 2999 | }
|
---|
| 3000 | }
|
---|
| 3001 | }
|
---|
| 3002 | return 0;
|
---|
[2] | 3003 |
|
---|
[551] | 3004 | case CN_DROP:
|
---|
| 3005 | if (mp2) {
|
---|
[2] | 3006 |
|
---|
[551] | 3007 | LISTINFO *li;
|
---|
[2] | 3008 |
|
---|
[551] | 3009 | DosBeep(500, 100); // fixme to know why beep?
|
---|
| 3010 | li = DoFileDrop(hwnd, dcd->arcname, FALSE, mp1, mp2);
|
---|
| 3011 | DosBeep(50, 100); // fixme to know why beep?
|
---|
| 3012 | if (li) {
|
---|
| 3013 | li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
|
---|
| 3014 | strcpy(li->targetpath, dcd->arcname);
|
---|
| 3015 | if (!li->list ||
|
---|
| 3016 | !li->list[0] ||
|
---|
| 3017 | !PostMsg(dcd->hwndObject, UM_ACTION, MPFROMP(li), MPVOID))
|
---|
| 3018 | FreeListInfo(li);
|
---|
| 3019 | }
|
---|
| 3020 | }
|
---|
| 3021 | return 0;
|
---|
[2] | 3022 |
|
---|
[551] | 3023 | case CN_CONTEXTMENU:
|
---|
| 3024 | {
|
---|
| 3025 | PARCITEM pci = (PARCITEM) mp2;
|
---|
[2] | 3026 |
|
---|
[551] | 3027 | if (pci) {
|
---|
| 3028 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
| 3029 | MPFROM2SHORT(TRUE, CRA_CURSORED));
|
---|
| 3030 | MarkAll(hwnd, FALSE, FALSE, TRUE);
|
---|
| 3031 | dcd->hwndLastMenu = CheckMenu(&ArcMenu, ARC_POPUP);
|
---|
| 3032 | }
|
---|
| 3033 | else {
|
---|
| 3034 | dcd->hwndLastMenu = CheckMenu(&ArcCnrMenu, ARCCNR_POPUP);
|
---|
| 3035 | if (dcd->hwndLastMenu && !dcd->cnremphasized) {
|
---|
| 3036 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
|
---|
| 3037 | MPFROM2SHORT(TRUE, CRA_SOURCE));
|
---|
| 3038 | dcd->cnremphasized = TRUE;
|
---|
| 3039 | }
|
---|
| 3040 | }
|
---|
| 3041 | if (dcd->hwndLastMenu) {
|
---|
| 3042 | if (dcd->hwndLastMenu == ArcCnrMenu) {
|
---|
| 3043 | if (dcd->flWindowAttr & CV_MINI)
|
---|
| 3044 | WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
|
---|
| 3045 | }
|
---|
| 3046 | WinCheckMenuItem(dcd->hwndLastMenu, IDM_FOLDERAFTEREXTRACT,
|
---|
| 3047 | fFolderAfterExtract);
|
---|
| 3048 | if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
|
---|
| 3049 | if (dcd->cnremphasized) {
|
---|
| 3050 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
|
---|
| 3051 | MPFROM2SHORT(FALSE, CRA_SOURCE));
|
---|
| 3052 | dcd->cnremphasized = TRUE;
|
---|
| 3053 | }
|
---|
| 3054 | MarkAll(hwnd, TRUE, FALSE, TRUE);
|
---|
| 3055 | }
|
---|
| 3056 | }
|
---|
| 3057 | }
|
---|
| 3058 | break;
|
---|
[2] | 3059 |
|
---|
[551] | 3060 | case CN_EMPHASIS:
|
---|
| 3061 | if (mp2) {
|
---|
[2] | 3062 |
|
---|
[551] | 3063 | PNOTIFYRECORDEMPHASIS pre = mp2;
|
---|
| 3064 | PARCITEM pci;
|
---|
| 3065 | CHAR s[CCHMAXPATHCOMP + 91], tf[81], tb[81];
|
---|
[2] | 3066 |
|
---|
[551] | 3067 | pci = (PARCITEM) ((pre) ? pre->pRecord : NULL);
|
---|
| 3068 | if (!pci) {
|
---|
| 3069 | if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
| 3070 | if (hwndStatus2)
|
---|
| 3071 | WinSetWindowText(hwndStatus2, NullStr);
|
---|
| 3072 | if (fMoreButtons)
|
---|
| 3073 | WinSetWindowText(hwndName, NullStr);
|
---|
| 3074 | }
|
---|
| 3075 | break;
|
---|
| 3076 | }
|
---|
| 3077 | if (pre->fEmphasisMask & CRA_SELECTED) {
|
---|
| 3078 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
| 3079 | dcd->selectedbytes += pci->cbFile;
|
---|
| 3080 | dcd->selectedfiles++;
|
---|
| 3081 | }
|
---|
| 3082 | else if (dcd->selectedfiles) {
|
---|
| 3083 | dcd->selectedbytes -= pci->cbFile;
|
---|
| 3084 | dcd->selectedfiles--;
|
---|
| 3085 | }
|
---|
| 3086 | commafmt(tf, sizeof(tf), dcd->selectedfiles);
|
---|
| 3087 | if (dcd->ullTotalBytes)
|
---|
| 3088 | CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
|
---|
| 3089 | else
|
---|
| 3090 | *tb = 0;
|
---|
| 3091 | sprintf(s, "%s%s%s", tf, *tb ? " / " : NullStr, tb);
|
---|
| 3092 | WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
|
---|
| 3093 | }
|
---|
| 3094 | else if (WinQueryActiveWindow(dcd->hwndParent) ==
|
---|
| 3095 | dcd->hwndFrame &&
|
---|
| 3096 | !ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
| 3097 | if (pre->fEmphasisMask & CRA_CURSORED) {
|
---|
| 3098 | if (pci->rc.flRecordAttr & CRA_CURSORED) {
|
---|
| 3099 | if (fSplitStatus && hwndStatus2) {
|
---|
| 3100 | if (dcd->ullTotalBytes)
|
---|
| 3101 | CommaFmtULL(tb, sizeof(tb), pci->cbFile, ' ');
|
---|
| 3102 | else
|
---|
| 3103 | *tb = 0;
|
---|
| 3104 | sprintf(s, "%s%s%s%s",
|
---|
| 3105 | *tb ? " " : NullStr,
|
---|
| 3106 | tb, *tb ? " " : NullStr, pci->szFileName);
|
---|
| 3107 | WinSetWindowText(hwndStatus2, s);
|
---|
| 3108 | }
|
---|
| 3109 | if (fMoreButtons)
|
---|
| 3110 | WinSetWindowText(hwndName, pci->szFileName);
|
---|
| 3111 | }
|
---|
| 3112 | }
|
---|
| 3113 | }
|
---|
| 3114 | }
|
---|
| 3115 | break;
|
---|
[2] | 3116 |
|
---|
[551] | 3117 | case CN_ENTER:
|
---|
| 3118 | if (mp2) {
|
---|
[2] | 3119 |
|
---|
[551] | 3120 | PARCITEM pci = (PARCITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
|
---|
[2] | 3121 |
|
---|
[551] | 3122 | if (pci) {
|
---|
[2] | 3123 |
|
---|
[551] | 3124 | CHAR *s;
|
---|
[2] | 3125 |
|
---|
[551] | 3126 | if ((pci->rc.flRecordAttr & CRA_INUSE) ||
|
---|
| 3127 | (pci->flags & (ARCFLAGS_REALDIR | ARCFLAGS_PSEUDODIR)))
|
---|
| 3128 | break;
|
---|
| 3129 | s = xstrdup(pci->szFileName, pszSrcFile, __LINE__);
|
---|
| 3130 | if (s) {
|
---|
| 3131 | if (!PostMsg(dcd->hwndObject, UM_ENTER, MPFROMP(s), MPVOID)) {
|
---|
| 3132 | Runtime_Error(pszSrcFile, __LINE__, "post");
|
---|
| 3133 | free(s);
|
---|
| 3134 | }
|
---|
| 3135 | }
|
---|
| 3136 | }
|
---|
| 3137 | }
|
---|
| 3138 | break;
|
---|
[2] | 3139 | }
|
---|
[551] | 3140 | }
|
---|
| 3141 | return 0;
|
---|
[2] | 3142 |
|
---|
[551] | 3143 | case UM_FOLDUP:
|
---|
| 3144 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
| 3145 | DosExit(EXIT_PROCESS, 1);
|
---|
| 3146 | return 0;
|
---|
[2] | 3147 |
|
---|
[551] | 3148 | case UM_CLOSE:
|
---|
| 3149 | WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 3150 | QW_PARENT));
|
---|
| 3151 | return 0;
|
---|
[2] | 3152 |
|
---|
[551] | 3153 | case WM_SAVEAPPLICATION:
|
---|
| 3154 | if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
| 3155 | SWP swp;
|
---|
[2] | 3156 |
|
---|
[551] | 3157 | WinQueryWindowPos(dcd->hwndFrame, &swp);
|
---|
| 3158 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
|
---|
| 3159 | PrfWriteProfileData(fmprof, appname, "AV2SizePos", &swp, sizeof(swp));
|
---|
| 3160 | }
|
---|
| 3161 | break;
|
---|
[2] | 3162 |
|
---|
[551] | 3163 | case WM_CLOSE:
|
---|
| 3164 | WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
|
---|
| 3165 | if (dcd)
|
---|
| 3166 | dcd->stopflag++;
|
---|
| 3167 | if (dcd && dcd->hwndObject) {
|
---|
| 3168 | if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
|
---|
| 3169 | WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 3170 | }
|
---|
| 3171 | // In case object window frees dcd
|
---|
| 3172 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 3173 | if (!dcd ||
|
---|
| 3174 | (!dcd->dontclose &&
|
---|
| 3175 | !dcd->amextracted && ParentIsDesktop(hwnd, dcd->hwndParent))) {
|
---|
| 3176 | if (!PostMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID))
|
---|
| 3177 | WinSendMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID);
|
---|
| 3178 | }
|
---|
| 3179 | return 0;
|
---|
| 3180 |
|
---|
| 3181 | case WM_DESTROY:
|
---|
| 3182 | if (ArcMenu)
|
---|
| 3183 | WinDestroyWindow(ArcMenu);
|
---|
| 3184 | if (ArcCnrMenu)
|
---|
| 3185 | WinDestroyWindow(ArcCnrMenu);
|
---|
| 3186 | ArcMenu = ArcCnrMenu = (HWND) 0;
|
---|
| 3187 | EmptyCnr(hwnd);
|
---|
| 3188 | break;
|
---|
[2] | 3189 | }
|
---|
[551] | 3190 | return (dcd && dcd->oldproc) ? dcd->oldproc(hwnd, msg, mp1, mp2) :
|
---|
| 3191 | PFNWPCnr(hwnd, msg, mp1, mp2);
|
---|
[2] | 3192 | }
|
---|
| 3193 |
|
---|
[551] | 3194 | HWND StartArcCnr(HWND hwndParent, HWND hwndCaller, CHAR * arcname, INT flags,
|
---|
| 3195 | ARC_TYPE * sinfo)
|
---|
[212] | 3196 | {
|
---|
[2] | 3197 | /*
|
---|
| 3198 | * bitmapped flags:
|
---|
| 3199 | * 1 = am extracted from another archive
|
---|
| 3200 | * 4 = don't kill proc on close
|
---|
| 3201 | */
|
---|
| 3202 |
|
---|
[551] | 3203 | HWND hwndFrame = (HWND) 0, hwndClient;
|
---|
| 3204 | ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
|
---|
| 3205 | FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
|
---|
| 3206 | USHORT id;
|
---|
| 3207 | DIRCNRDATA *dcd;
|
---|
| 3208 | ARC_TYPE *info = sinfo;
|
---|
| 3209 | CHAR title[MAXNAMEL + 1] = "AV/2 - ";
|
---|
| 3210 | CHAR fullname[CCHMAXPATH + 8], *p, temp;
|
---|
[2] | 3211 | static USHORT idinc = 0;
|
---|
| 3212 |
|
---|
[423] | 3213 | if (!idinc)
|
---|
[2] | 3214 | idinc = (rand() % 256);
|
---|
[551] | 3215 | if (ParentIsDesktop(hwndParent, hwndParent))
|
---|
[2] | 3216 | FrameFlags |= (FCF_TASKLIST | FCF_MENU);
|
---|
[423] | 3217 | if (arcname) {
|
---|
[2] | 3218 | DosError(FERR_DISABLEHARDERR);
|
---|
[423] | 3219 | if (DosQueryPathInfo(arcname,
|
---|
[551] | 3220 | FIL_QUERYFULLNAME, fullname, sizeof(fullname)))
|
---|
| 3221 | strcpy(fullname, arcname);
|
---|
[2] | 3222 | p = fullname;
|
---|
[551] | 3223 | while (*p) {
|
---|
[423] | 3224 | if (*p == '/')
|
---|
[551] | 3225 | *p = '\\';
|
---|
[2] | 3226 | p++;
|
---|
| 3227 | }
|
---|
[423] | 3228 | if (!info)
|
---|
[551] | 3229 | info = find_type(fullname, arcsighead);
|
---|
[423] | 3230 | if (!info)
|
---|
[2] | 3231 | return hwndFrame;
|
---|
[551] | 3232 | if (strlen(title) + strlen(fullname) > MAXNAMEL) {
|
---|
| 3233 | p = title + strlen(title);
|
---|
| 3234 | strncpy(p, fullname, MAXNAMEL / 2 - 5);
|
---|
| 3235 | strcpy(p + MAXNAMEL / 2 - 5, "...");
|
---|
| 3236 | strcat(title, fullname + strlen(fullname) - (MAXNAMEL / 2 - 5));
|
---|
[460] | 3237 | }
|
---|
[551] | 3238 | else {
|
---|
| 3239 | strcat(title, fullname);
|
---|
[460] | 3240 | }
|
---|
[2] | 3241 | hwndFrame = WinCreateStdWindow(hwndParent,
|
---|
[551] | 3242 | WS_VISIBLE,
|
---|
| 3243 | &FrameFlags,
|
---|
| 3244 | GetPString(IDS_WCARCCONTAINER),
|
---|
| 3245 | title,
|
---|
| 3246 | WS_VISIBLE | fwsAnimate,
|
---|
| 3247 | FM3ModHandle, ARC_FRAME, &hwndClient);
|
---|
[423] | 3248 | if (hwndFrame && hwndClient) {
|
---|
[2] | 3249 | id = ARC_FRAME + idinc++;
|
---|
[423] | 3250 | if (idinc > 512)
|
---|
[551] | 3251 | idinc = 0;
|
---|
| 3252 | WinSetWindowUShort(hwndFrame, QWS_ID, id);
|
---|
| 3253 | dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
|
---|
[358] | 3254 | if (!dcd) {
|
---|
[551] | 3255 | PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 3256 | hwndFrame = (HWND) 0;
|
---|
[358] | 3257 | }
|
---|
| 3258 | else {
|
---|
[551] | 3259 | dcd->size = sizeof(DIRCNRDATA);
|
---|
| 3260 | dcd->id = id;
|
---|
| 3261 | dcd->type = ARC_FRAME;
|
---|
| 3262 | save_dir2(dcd->workdir);
|
---|
| 3263 | if (dcd->workdir[strlen(dcd->workdir) - 1] != '\\')
|
---|
| 3264 | strcat(dcd->workdir, "\\");
|
---|
| 3265 | sprintf(dcd->workdir + strlen(dcd->workdir), "%s.%03x",
|
---|
| 3266 | ArcTempRoot, (clock() & 4095));
|
---|
| 3267 | strcpy(dcd->arcname, fullname);
|
---|
| 3268 | if (*extractpath) {
|
---|
| 3269 | if (!strcmp(extractpath, "*")) {
|
---|
| 3270 | p = strrchr(fullname, '\\');
|
---|
| 3271 | if (p) {
|
---|
| 3272 | if (p < fullname + 3)
|
---|
| 3273 | p++;
|
---|
| 3274 | temp = *p;
|
---|
| 3275 | *p = 0;
|
---|
| 3276 | strcpy(dcd->directory, fullname);
|
---|
| 3277 | *p = temp;
|
---|
| 3278 | }
|
---|
| 3279 | }
|
---|
| 3280 | else
|
---|
| 3281 | strcpy(dcd->directory, extractpath);
|
---|
| 3282 | }
|
---|
| 3283 | if (!*dcd->directory && *lastextractpath) {
|
---|
| 3284 | DosEnterCritSec();
|
---|
| 3285 | strcpy(dcd->directory, lastextractpath);
|
---|
| 3286 | DosExitCritSec();
|
---|
| 3287 | }
|
---|
| 3288 | if (!*dcd->directory) {
|
---|
| 3289 | if (!ParentIsDesktop(hwndParent, hwndParent))
|
---|
| 3290 | TopWindowName(hwndParent, hwndCaller, dcd->directory);
|
---|
| 3291 | if (!*dcd->directory) {
|
---|
| 3292 | p = strrchr(fullname, '\\');
|
---|
| 3293 | if (p) {
|
---|
| 3294 | if (p < fullname + 3)
|
---|
| 3295 | p++;
|
---|
| 3296 | *p = 0;
|
---|
| 3297 | strcpy(dcd->directory, fullname);
|
---|
| 3298 | }
|
---|
| 3299 | }
|
---|
| 3300 | }
|
---|
| 3301 | if (!*dcd->directory ||
|
---|
| 3302 | IsFile(dcd->directory) ||
|
---|
| 3303 | (isalpha(*dcd->directory) &&
|
---|
| 3304 | (driveflags[toupper(*dcd->directory) - 'A'] &
|
---|
| 3305 | DRIVE_NOTWRITEABLE)))
|
---|
| 3306 | save_dir2(dcd->directory);
|
---|
| 3307 | dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
|
---|
| 3308 | dcd->hwndFrame = hwndFrame;
|
---|
| 3309 | dcd->hwndClient = hwndClient;
|
---|
| 3310 | dcd->amextracted = ((flags & 1) != 0);
|
---|
| 3311 | dcd->dontclose = ((flags & 4) != 0);
|
---|
| 3312 | dcd->info = info;
|
---|
| 3313 | dcd->sortFlags = DefArcSortFlags;
|
---|
| 3314 | {
|
---|
| 3315 | PFNWP oldproc;
|
---|
[2] | 3316 |
|
---|
[551] | 3317 | oldproc = WinSubclassWindow(hwndFrame, (PFNWP) ArcFrameWndProc);
|
---|
| 3318 | WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
|
---|
[358] | 3319 | }
|
---|
[551] | 3320 | dcd->hwndCnr = WinCreateWindow(hwndClient,
|
---|
| 3321 | WC_CONTAINER,
|
---|
| 3322 | NULL,
|
---|
| 3323 | CCS_AUTOPOSITION | CCS_MINIICONS |
|
---|
| 3324 | CCS_MINIRECORDCORE | ulCnrType |
|
---|
| 3325 | WS_VISIBLE,
|
---|
| 3326 | 0,
|
---|
| 3327 | 0,
|
---|
| 3328 | 0,
|
---|
| 3329 | 0,
|
---|
| 3330 | hwndClient,
|
---|
| 3331 | HWND_TOP, (ULONG) ARC_CNR, NULL, NULL);
|
---|
| 3332 | if (!dcd->hwndCnr) {
|
---|
| 3333 | Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
|
---|
| 3334 | IDS_WINCREATEWINDOW);
|
---|
| 3335 | PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 3336 | free(dcd);
|
---|
| 3337 | hwndFrame = (HWND) 0;
|
---|
| 3338 | }
|
---|
[358] | 3339 | else {
|
---|
[551] | 3340 | WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
|
---|
| 3341 | dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
|
---|
| 3342 | (PFNWP) ArcCnrWndProc);
|
---|
| 3343 | {
|
---|
| 3344 | USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
|
---|
| 3345 | DIR_FILTER, DIR_FOLDERICON, 0
|
---|
| 3346 | };
|
---|
[2] | 3347 |
|
---|
[551] | 3348 | CommonCreateTextChildren(dcd->hwndClient,
|
---|
| 3349 | GetPString(IDS_WCARCSTATUS), ids);
|
---|
| 3350 | }
|
---|
| 3351 | WinEnableWindow(WinWindowFromID(dcd->hwndClient, DIR_VIEW), FALSE);
|
---|
| 3352 | dcd->hwndExtract = WinCreateWindow(dcd->hwndClient,
|
---|
| 3353 | WC_ENTRYFIELD,
|
---|
| 3354 | NULL,
|
---|
| 3355 | ES_AUTOSCROLL,
|
---|
| 3356 | 0,
|
---|
| 3357 | 0,
|
---|
| 3358 | 0,
|
---|
| 3359 | 0,
|
---|
| 3360 | dcd->hwndClient,
|
---|
| 3361 | HWND_TOP,
|
---|
| 3362 | ARC_EXTRACTDIR, NULL, NULL);
|
---|
| 3363 | WinSendMsg(dcd->hwndExtract,
|
---|
| 3364 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 3365 | WinSetWindowText(dcd->hwndExtract, dcd->directory);
|
---|
| 3366 | if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
|
---|
| 3367 | WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
|
---|
| 3368 | if (FrameFlags & FCF_MENU) {
|
---|
| 3369 | if (!fToolbar) {
|
---|
| 3370 | HWND hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
|
---|
[2] | 3371 |
|
---|
[551] | 3372 | if (hwndMenu) {
|
---|
| 3373 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3374 | MPFROM2SHORT(IDM_VIEW, FALSE), MPVOID);
|
---|
| 3375 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3376 | MPFROM2SHORT(IDM_EXEC, FALSE), MPVOID);
|
---|
| 3377 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3378 | MPFROM2SHORT(IDM_RESCAN, FALSE), MPVOID);
|
---|
| 3379 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3380 | MPFROM2SHORT(IDM_DELETE, FALSE), MPVOID);
|
---|
| 3381 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3382 | MPFROM2SHORT(IDM_EXTRACT, FALSE), MPVOID);
|
---|
| 3383 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3384 | MPFROM2SHORT(IDM_TEST, FALSE), MPVOID);
|
---|
| 3385 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3386 | MPFROM2SHORT(IDM_VIRUSSCAN, FALSE), MPVOID);
|
---|
| 3387 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3388 | MPFROM2SHORT(IDM_WALKDIR, FALSE), MPVOID);
|
---|
| 3389 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3390 | MPFROM2SHORT(IDM_FILTER, FALSE), MPVOID);
|
---|
| 3391 | }
|
---|
| 3392 | }
|
---|
| 3393 | }
|
---|
| 3394 | if (FrameFlags & FCF_TASKLIST) {
|
---|
[2] | 3395 |
|
---|
[551] | 3396 | SWP swp, swpD;
|
---|
| 3397 | ULONG size = sizeof(swp);
|
---|
| 3398 | LONG cxScreen, cyScreen;
|
---|
[2] | 3399 |
|
---|
[551] | 3400 | WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
|
---|
| 3401 | if (PrfQueryProfileData(fmprof,
|
---|
| 3402 | appname, "AV2SizePos", &swpD, &size)) {
|
---|
| 3403 | cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
|
---|
| 3404 | cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
|
---|
| 3405 | if (swp.x + swpD.cx > cxScreen)
|
---|
| 3406 | swp.x = cxScreen - swpD.cx;
|
---|
| 3407 | if (swp.y + swpD.cy > cyScreen)
|
---|
| 3408 | swp.y = cyScreen - swpD.cy;
|
---|
| 3409 | swp.cx = swpD.cx;
|
---|
| 3410 | swp.cy = swpD.cy;
|
---|
| 3411 | }
|
---|
| 3412 | WinSetWindowPos(hwndFrame,
|
---|
| 3413 | HWND_TOP,
|
---|
| 3414 | swp.x,
|
---|
| 3415 | swp.y,
|
---|
| 3416 | swp.cx,
|
---|
| 3417 | swp.cy,
|
---|
| 3418 | SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
|
---|
| 3419 | SWP_ACTIVATE);
|
---|
| 3420 | }
|
---|
| 3421 | }
|
---|
[2] | 3422 | }
|
---|
| 3423 | }
|
---|
| 3424 | }
|
---|
| 3425 | return hwndFrame;
|
---|
| 3426 | }
|
---|