Changeset 1566
- Timestamp:
- May 31, 2011, 9:11:14 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/filter.c
r1544 r1566 4 4 $Id$ 5 5 6 Filter mask select dialog6 Filter mask check and select dialog 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2004, 201 0Steven H.Levine9 Copyright (c) 2004, 2011 Steven H.Levine 10 10 11 11 01 Aug 04 SHL Rework lstrip/rstrip usage … … 20 20 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook. 21 21 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *. 22 31 May 11 SHL Rework Filter() for speed 22 23 23 24 ***********************************************************************/ … … 40 41 #include "errutil.h" // Dos_Error... 41 42 #include "strutil.h" // GetPString 42 #include "pathutil.h" 43 #include "pathutil.h" // BldFullPathName 43 44 #include "filter.h" 44 45 #include "select.h" // SetMask … … 68 69 /** 69 70 * Filter callback 71 * @return TRUE if filter condition matched and item will be visible 70 72 */ 71 73 72 74 INT APIENTRY Filter(PMINIRECORDCORE rmini, PVOID arg) 73 75 { 74 75 MASK *mask = (MASK *) arg; 76 PCNRITEM r; 76 MASK *mask = (MASK *)arg; 77 PCNRITEM pci; 77 78 INT x; 78 INT ret = FALSE;79 INT matched; 79 80 CHAR *file; 80 81 81 if (mask) { 82 r = (PCNRITEM) rmini; 83 if (!(*(r->pszFileName + 3)) 84 || (mask->fShowDirs && (r->attrFile & FILE_DIRECTORY))) 85 return TRUE; 86 if ((!(mask->attrFile & FILE_HIDDEN) && (r->attrFile & FILE_HIDDEN)) || 87 (!(mask->attrFile & FILE_SYSTEM) && (r->attrFile & FILE_SYSTEM)) || 88 (!(mask->attrFile & FILE_READONLY) && (r->attrFile & FILE_READONLY)) 89 || (!(mask->attrFile & FILE_ARCHIVED) 90 && (r->attrFile & FILE_ARCHIVED)) 91 || (!(mask->attrFile & FILE_DIRECTORY) 92 && (r->attrFile & FILE_DIRECTORY))) 93 return FALSE; 94 if (((mask->antiattr & FILE_HIDDEN) && !(r->attrFile & FILE_HIDDEN)) || 95 ((mask->antiattr & FILE_SYSTEM) && !(r->attrFile & FILE_SYSTEM)) || 96 ((mask->antiattr & FILE_READONLY) && !(r->attrFile & FILE_READONLY)) 97 || ((mask->antiattr & FILE_ARCHIVED) 98 && !(r->attrFile & FILE_ARCHIVED)) 99 || ((mask->antiattr & FILE_DIRECTORY) 100 && !(r->attrFile & FILE_DIRECTORY))) 101 return FALSE; 102 if (*mask->szMask) { 103 file = strrchr(r->pszFileName, '\\'); 104 if (!file) 105 file = strrchr(r->pszFileName, ':'); 106 if (file) 107 file++; 108 else 109 file = r->pszFileName; 110 if (mask->pszMasks[1]) { 111 for (x = 0; mask->pszMasks[x]; x++) { 112 if (*mask->pszMasks[x]) { 113 if (*mask->pszMasks[x] != '/') { 114 if (wildcard((strchr(mask->pszMasks[x], '\\') || 115 strchr(mask->pszMasks[x], ':')) ? 116 r->pszFileName : file, mask->pszMasks[x], FALSE)) 117 ret = TRUE; 118 } 119 else { 120 if (wildcard((strchr(mask->pszMasks[x], '\\') || 121 strchr(mask->pszMasks[x], ':')) ? 122 r->pszFileName : file, mask->pszMasks[x] + 1, 123 FALSE)) { 124 ret = FALSE; 125 break; 126 } 127 } 128 } 129 } 82 if (!mask) 83 return TRUE; // No mask data 84 85 pci = (PCNRITEM) rmini; 86 // Always show root directory 87 // 2011-05-31 SHL fixme to know if this is correct 88 if (!(*(pci->pszFileName + 3)) 89 || mask->fShowDirs && (pci->attrFile & FILE_DIRECTORY)) 90 return TRUE; 91 92 if ((~mask->attrFile & FILE_HIDDEN && pci->attrFile & FILE_HIDDEN) || 93 (~mask->attrFile & FILE_SYSTEM && pci->attrFile & FILE_SYSTEM) || 94 (~mask->attrFile & FILE_READONLY && pci->attrFile & FILE_READONLY) || 95 (~mask->attrFile & FILE_ARCHIVED && pci->attrFile & FILE_ARCHIVED) || 96 (~mask->attrFile & FILE_DIRECTORY && pci->attrFile & FILE_DIRECTORY)) 97 return FALSE; 98 99 if ((mask->antiattr & FILE_HIDDEN && ~pci->attrFile & FILE_HIDDEN) || 100 (mask->antiattr & FILE_SYSTEM && ~pci->attrFile & FILE_SYSTEM) || 101 (mask->antiattr & FILE_READONLY && ~pci->attrFile & FILE_READONLY) || 102 (mask->antiattr & FILE_ARCHIVED && ~pci->attrFile & FILE_ARCHIVED) || 103 (mask->antiattr & FILE_DIRECTORY && ~pci->attrFile & FILE_DIRECTORY)) 104 return FALSE; 105 106 if (!*mask->szMask) 107 return TRUE; // No masks 108 109 // Have mask string 110 file = strrchr(pci->pszFileName, '\\'); 111 if (!file) 112 file = strrchr(pci->pszFileName, ':'); 113 if (file) 114 file++; // Point after drive spec 115 else 116 file = pci->pszFileName; 117 118 if (!mask->pszMasks[1]) { 119 // Just one mask string 120 return wildcard(strchr(mask->szMask, '\\') || 121 strchr(mask->szMask, ':') ? 122 pci->pszFileName : file, 123 mask->szMask, 124 FALSE); 125 } 126 127 // Have multiple mask strings 128 matched = FALSE; 129 for (x = 0; mask->pszMasks[x]; x++) { 130 if (*mask->pszMasks[x]) { 131 if (*mask->pszMasks[x] != '/') { 132 if (wildcard((strchr(mask->pszMasks[x], '\\') || 133 strchr(mask->pszMasks[x], ':')) ? 134 pci->pszFileName : file, 135 mask->pszMasks[x], 136 FALSE)) 137 { 138 matched = TRUE; 139 } 130 140 } 131 141 else { 132 if (wildcard((strchr(mask->szMask, '\\') || 133 strchr(mask->szMask, ':')) ? 134 r->pszFileName : file, mask->szMask, FALSE)) 135 ret = TRUE; 136 } 137 } 138 else 139 ret = TRUE; 140 } 141 else 142 ret = TRUE; 143 return ret; 142 // Check for non-match 143 if (wildcard(strchr(mask->pszMasks[x], '\\') || 144 strchr(mask->pszMasks[x], ':') ? 145 pci->pszFileName : file, mask->pszMasks[x] + 1, 146 FALSE)) 147 { 148 matched = FALSE; 149 break; 150 } 151 } 152 } 153 } // for 154 155 return matched; 144 156 } 145 157 … … 179 191 } 180 192 } 181 } 193 } //while 182 194 fclose(fp); 183 195 } … … 327 339 WinCheckButton(hwnd, MSK_HIDDEN, (mask->attrFile & FILE_HIDDEN) != 0); 328 340 WinCheckButton(hwnd, MSK_READONLY, 329 341 (mask->attrFile & FILE_READONLY) != 0); 330 342 WinCheckButton(hwnd, MSK_ARCHIVED, 331 343 (mask->attrFile & FILE_ARCHIVED) != 0); 332 344 WinCheckButton(hwnd, MSK_DIRECTORY, 333 345 (mask->attrFile & FILE_DIRECTORY) != 0); 334 346 WinCheckButton(hwnd, MSK_MUSTSYSTEM, 335 347 (mask->antiattr & FILE_SYSTEM) != 0); 336 348 WinCheckButton(hwnd, MSK_MUSTHIDDEN, 337 349 (mask->antiattr & FILE_HIDDEN) != 0); 338 350 WinCheckButton(hwnd, MSK_MUSTREADONLY, 339 351 (mask->antiattr & FILE_READONLY) != 0); 340 352 WinCheckButton(hwnd, MSK_MUSTARCHIVED, 341 353 (mask->antiattr & FILE_ARCHIVED) != 0); 342 354 WinCheckButton(hwnd, MSK_MUSTDIRECTORY, 343 355 (mask->antiattr & FILE_DIRECTORY) != 0); 344 356 if (mask->fNoDirs) 345 357 WinEnableWindow(WinWindowFromID(hwnd, MSK_SHOWDIRS), FALSE); 346 358 else 347 359 WinCheckButton(hwnd, MSK_SHOWDIRS, (mask->fShowDirs != FALSE)); 348 360 WinEnableWindow(WinWindowFromID(hwnd, MSK_MUSTSYSTEM), 349 361 (mask->attrFile & FILE_SYSTEM) != 0); 350 362 WinEnableWindow(WinWindowFromID(hwnd, MSK_MUSTHIDDEN), 351 363 (mask->attrFile & FILE_HIDDEN) != 0); 352 364 WinEnableWindow(WinWindowFromID(hwnd, MSK_MUSTARCHIVED), 353 365 (mask->attrFile & FILE_ARCHIVED) != 0); 354 366 WinEnableWindow(WinWindowFromID(hwnd, MSK_MUSTREADONLY), 355 367 (mask->attrFile & FILE_READONLY) != 0); 356 368 WinEnableWindow(WinWindowFromID(hwnd, MSK_MUSTDIRECTORY), 357 369 (mask->attrFile & FILE_DIRECTORY) != 0); 358 370 } 359 371 if (*mask->szMask) { … … 362 374 strcpy(s, mask->szMask); 363 375 if (!strchr(mask->szMask, '?') && !strchr(mask->szMask, '*')) { 364 365 366 367 368 376 p = strrchr(mask->szMask, '.'); 377 if (p && *(p + 1)) { 378 *s = '*'; 379 strcpy(s + 1, p); 380 } 369 381 } 370 382 WinSetDlgItemText(hwnd, MSK_MASK, s); 371 383 WinSendDlgItemMsg(hwnd, MSK_MASK, EM_SETSEL, 372 384 MPFROM2SHORT(0, CCHMAXPATH), MPVOID); 373 385 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID); 374 386 } … … 425 437 50, 426 438 swpE.cy, hwnd, HWND_TOP, 65535, NULL, NULL)) { 427 428 439 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 440 PCSZ_WINCREATEWINDOW); 429 441 } 430 442 if (!WinCreateWindow(hwnd, … … 437 449 swpL.cx - 54, 438 450 swpE.cy, hwnd, HWND_TOP, MSK_TEXT, NULL, NULL)) { 439 440 451 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, 452 PCSZ_WINCREATEWINDOW); 441 453 } 442 454 WinSendDlgItemMsg(hwnd, MSK_TEXT, … … 521 533 case LN_SELECT: 522 534 { 523 535 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, 524 536 MSK_LISTBOX, 525 537 LM_QUERYSELECTION, … … 584 596 } 585 597 } 586 / * intentional fallthru */598 // intentional fallthru 587 599 case MSK_CLEAR: 588 600 WinSetDlgItemText(hwnd, MSK_MASK, NullStr); … … 592 604 case DID_OK: 593 605 { 594 595 606 mask = INSTDATA(hwnd); 596 607 *s = 0; … … 600 611 if (SHORT1FROMMP(mp1) == DID_OK) { 601 612 mask->attrFile = 602 (WinQueryButtonCheckstate(hwnd, MSK_SYSTEM) * 603 FILE_SYSTEM) | (WinQueryButtonCheckstate(hwnd, 604 MSK_HIDDEN) * 605 FILE_HIDDEN) | (WinQueryButtonCheckstate(hwnd, 606 MSK_READONLY) 607 * 608 FILE_READONLY) | 609 (WinQueryButtonCheckstate(hwnd, MSK_ARCHIVED) * 610 FILE_ARCHIVED) | (WinQueryButtonCheckstate(hwnd, 611 MSK_DIRECTORY) * 612 FILE_DIRECTORY); 613 (WinQueryButtonCheckstate(hwnd, MSK_SYSTEM) * FILE_SYSTEM) | 614 (WinQueryButtonCheckstate(hwnd, MSK_HIDDEN) * FILE_HIDDEN) | 615 (WinQueryButtonCheckstate(hwnd, MSK_READONLY) * FILE_READONLY) | 616 (WinQueryButtonCheckstate(hwnd, MSK_ARCHIVED) * FILE_ARCHIVED) | 617 (WinQueryButtonCheckstate(hwnd, MSK_DIRECTORY) * FILE_DIRECTORY); 613 618 mask->antiattr = 614 (WinQueryButtonCheckstate(hwnd, MSK_MUSTSYSTEM) * 615 FILE_SYSTEM) | (WinQueryButtonCheckstate(hwnd, 616 MSK_MUSTHIDDEN) * 617 FILE_HIDDEN) | (WinQueryButtonCheckstate(hwnd, 618 MSK_MUSTREADONLY) 619 * 620 FILE_READONLY) | 621 (WinQueryButtonCheckstate(hwnd, MSK_MUSTARCHIVED) * 622 FILE_ARCHIVED) | (WinQueryButtonCheckstate(hwnd, 623 MSK_MUSTDIRECTORY) * 624 FILE_DIRECTORY); 625 mask->fShowDirs = 626 (WinQueryButtonCheckstate(hwnd, MSK_SHOWDIRS) != FALSE); 619 (WinQueryButtonCheckstate(hwnd, MSK_MUSTSYSTEM) * FILE_SYSTEM) | 620 (WinQueryButtonCheckstate(hwnd, MSK_MUSTHIDDEN) * FILE_HIDDEN) | 621 (WinQueryButtonCheckstate(hwnd, MSK_MUSTREADONLY) * FILE_READONLY) | 622 (WinQueryButtonCheckstate(hwnd, MSK_MUSTARCHIVED) * FILE_ARCHIVED) | 623 (WinQueryButtonCheckstate(hwnd, MSK_MUSTDIRECTORY) * FILE_DIRECTORY); 624 mask->fShowDirs = WinQueryButtonCheckstate(hwnd, MSK_SHOWDIRS) != FALSE; 627 625 if (mask->fText) 628 626 WinQueryDlgItemText(hwnd, MSK_TEXT, 256, mask->szText); 629 627 } 630 628 if (*s) { 629 // Got mask string 631 630 if (SHORT1FROMMP(mp1) == DID_OK) { 632 631 strcpy(mask->szMask, s); … … 636 635 WinDismissDlg(hwnd, 1); 637 636 } 638 639 637 else { 638 // MSK_DELETE 640 639 WinSetDlgItemText(hwnd, MSK_MASK, NullStr); 641 640 remove_mask(s); … … 649 648 } 650 649 else { 650 // No mask string 651 651 if (SHORT1FROMMP(mp1) == DID_OK) { 652 652 *mask->szMask = 0; … … 655 655 } 656 656 else if (!fAlertBeepOff) 657 DosBeep(50, 100); // MSK_DELETE 657 DosBeep(50, 100); // MSK_DELETE not allowed here 658 658 } 659 659 }
Note:
See TracChangeset
for help on using the changeset viewer.