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