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