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