source: trunk/dll/arccnrs.c@ 1741

Last change on this file since 1741 was 1741, checked in by Gregg Young, 12 years ago

Fix warn readonly yes don't ask to work when recursing directories.

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