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