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