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