Changeset 1891 for trunk/dll/flesh.c
- Timestamp:
- Jan 31, 2020, 3:47:37 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/flesh.c
r1890 r1891 6 6 Drive tree container management 7 7 8 Copyright (c) 1993- 98 M. Kimes9 Copyright (c) 2005 , 2015Steven H. Levine8 Copyright (c) 1993-1998 M. Kimes 9 Copyright (c) 2005-2020 Steven H. Levine 10 10 11 11 24 May 05 SHL Rework Win_Error usage … … 38 38 23 Aug 15 GKY Fixed code to notify on drive with no subdirectories in first 64 entries 39 39 20 Sep 15 GKY Add code for Flesh to skip the directory entry added by Stubby (eliminate 40 41 42 40 use of NULL/Nullstr pszFileNames by Stubby). Add code in Stubby to insert a 41 complete container item. Add a flag to indicate when a directory needed to be 42 Fleshed 43 43 26 Sep 15 GKY Changes to speed up ExpandAll 44 44 26 Sep 15 GKY WaitFleshWorkListEmpty now gives error message and returns if semaphore request 45 45 fails more than 5 consecutive times. 46 46 27 Sep 15 GKY DosSleep times in WaitFleshWorkListEmpty set by caller 47 47 10 Oct 15 GKY Don't use Flesh thread for floppy drive scans fix them getting mistakenly identified 48 as directories and add nonexistent subdirectories. 48 as directories and add nonexistent subdirectories. 49 25 Jan 20 SHL Complain if AddFleshWorkRequest returns empty string 50 27 Jan 20 SHL Avoid more traps if passed bogus pciParent 49 51 50 52 ***********************************************************************/ … … 81 83 82 84 #ifdef PMPRINTF 83 #define 85 #define _PMPRINTF_ // Enable debug macros 84 86 #include "PMPRINTF.H" 85 87 #endif … … 92 94 static INT tidFleshWorkListThread = -1; // 2015-08-08 SHL 93 95 94 static PCSZ pszFleshFocusPath; // 2015-08-20 SHL96 static PCSZ pszFleshFocusPath; // 2015-08-20 SHL 95 97 96 98 #pragma data_seg(GLOBAL1) … … 193 195 ri.cRecordsInsert = 1; 194 196 ri.fInvalidateRecord = FALSE; 195 197 if (!WinSendMsg(hwndCnr, 196 198 CM_INSERTRECORD, MPFROMP(pciL), MPFROMP(&ri))) 197 199 FreeCnrItem(hwndCnr, pciL); … … 223 225 * @param hwnCnr is container to receive CNRITEMs 224 226 * @param pciParent is CNRITEM to have children inserted 225 * @return TRUE if OK, FALSE i serror detected227 * @return TRUE if OK, FALSE if error detected 226 228 */ 227 229 … … 241 243 if (!pciParent->fleshed) { 242 244 pciL = (PCNRITEM)WinSendMsg(hwndCnr, 243 244 245 245 CM_QUERYRECORD, 246 MPFROMP(pciParent), 247 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER)); 246 248 // Added by Stubby to create plus sign run Stubby on it here and skip it in ProcessDirectory 247 249 if (pciL && (INT)pciL != -1) { 248 250 AddFleshWorkRequest(hwndCnr, pciL, eStubby); 249 // 2015-08-06 SHL FIXME to ensure this can not happen 250 if (!*pciL->pszFileName || !strcmp(pciL->pszFileName, NullStr)) 251 Runtime_Error(pszSrcFile, __LINE__, "Flesh called with pci %p pszFileName (null)", 252 pciL); 251 /* Under some condtions AddFleshWorkRequest will return before pciL is populated 252 2015-08-06 SHL FIXME to ensure pciL->szFileName not empty string 253 2020-01-25 SHL FIXME to ensure pciL->szFileName not null 254 */ 255 if (!pciL->pszFileName || !*pciL->pszFileName || !strcmp(pciL->pszFileName, NullStr)) 256 DosSleep(250); 257 if (!pciL->pszFileName || !*pciL->pszFileName || !strcmp(pciL->pszFileName, NullStr)) { 258 Runtime_Error(pszSrcFile, __LINE__, "Flesh called with pci %p pszFileName %p = %s", 259 pciL, 260 pciL ? pciL->pszFileName : 0, 261 pciL ? pciL->pszFileName ? pciL->pszFileName : "(null)" : "(null)"); 262 return FALSE; 263 } 264 253 265 } 254 266 dcd = INSTDATA(hwndCnr); … … 269 281 dcd, 270 282 NULL, // total files 271 NULL,// total bytes272 283 NULL, // total bytes 284 (pciL && (INT)pciL != -1) ? pciL->pszDisplayName : 0); 273 285 pciParent->fleshed = TRUE; 274 286 return TRUE; … … 296 308 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER)); 297 309 if (!pciL || (INT)pciL == -1) 298 break; 310 break; 299 311 RemoveCnrItems(hwndCnr, pciL, 1, CMA_FREE); 300 312 removed = TRUE; … … 305 317 CM_INVALIDATERECORD, 306 318 MPFROMP(&pciParent), 307 319 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION)); 308 320 pciParent->fleshed = FALSE; 309 321 DosSleep(1); // Let container items go away … … 347 359 static BOOL brokenlan = FALSE, isbroken = FALSE; 348 360 349 if (!pciParent || (INT)pciParent == -1 || !*pciParent->pszFileName 350 || pciParent->pszFileName == NullStr || !hwndCnr) 361 // 2020-01-27 SHL FIXME to doc how can get here with unitialized pciParent 362 if (!pciParent || (INT)pciParent == -1|| 363 !pciParent->pszFileName || 364 !*pciParent->pszFileName || 365 pciParent->pszFileName == NullStr || 366 !hwndCnr) { 351 367 return FALSE; 368 } 369 352 370 // Build wildcard 353 371 len = strlen(pciParent->pszFileName); … … 507 525 (pffb->achName[1] != '.' || pffb->achName[2])))) 508 526 { 509 527 // Got directory other than . or .. (or a file) 510 528 isadir = TRUE; 511 529 break; … … 530 548 } 531 549 else { 532 533 534 535 536 537 538 539 540 pci->pszFileName = xstrdup(szBuffer, pszSrcFile, __LINE__);541 542 543 pci->pszDisplayName = p; 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 550 RECORDINSERT ri; 551 CHAR szBuffer[CCHMAXPATH + 14]; 552 CHAR *p; 553 HPOINTER hptr; 554 555 p = strchr(wildcard, '*'); 556 *p = 0;; 557 BldFullPathName(szBuffer, wildcard, pffb->achName); 558 pci->pszFileName = xstrdup(szBuffer, pszSrcFile, __LINE__); 559 p = strrchr(pci->pszFileName, '\\'); 560 p++; 561 pci->pszDisplayName = p; 562 pci->rc.pszIcon = pci->pszDisplayName; 563 if (fForceUpper) 564 strupr(pci->pszFileName); 565 else if (fForceLower) 566 strlwr(pci->pszFileName); 567 568 flags = driveflags[toupper(*pci->pszFileName) - 'A']; 569 570 // get an icon to use with it 571 if (pffb->attrFile & FILE_DIRECTORY) { 572 // is directory 573 if (fNoIconsDirs || 574 (flags & DRIVE_NOLOADICONS) || 575 !isalpha(*pci->pszFileName)) { 576 hptr = (HPOINTER) 0; 577 } 578 else 579 hptr = WinLoadFileIcon(pci->pszFileName, FALSE); 580 } 581 else { 582 // is file 583 if (fNoIconsFiles || 584 (flags & DRIVE_NOLOADICONS) || 585 !isalpha(*pci->pszFileName)) { 586 hptr = (HPOINTER) 0; 587 } 588 else 589 hptr = WinLoadFileIcon(pci->pszFileName, FALSE); 590 591 if (!hptr || IsDefaultIcon(hptr)) 592 hptr = IDFile(pci->pszFileName); 593 } 594 595 if (!hptr) { 596 hptr = pffb->attrFile & FILE_DIRECTORY ? 597 hptrDir : pffb->attrFile & FILE_SYSTEM ? 598 hptrSystem : pffb->attrFile & FILE_HIDDEN ? 599 hptrHidden : pffb->attrFile & FILE_READONLY ? 600 hptrReadonly : hptrFile; 601 } 602 pci->rc.hptrIcon = hptr; 585 603 memset(&ri, 0, sizeof(RECORDINSERT)); 586 604 ri.cb = sizeof(RECORDINSERT); … … 590 608 ri.cRecordsInsert = 1; 591 609 ri.fInvalidateRecord = TRUE; 592 610 if (!WinSendMsg(hwndCnr, 593 611 CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) { 594 612 // Assume busy and try again 595 DosSleep(50); 613 DosSleep(50); 596 614 WinSetFocus(HWND_DESKTOP, hwndCnr); 597 615 if (WinIsWindow((HAB)0, hwndCnr)) { 598 616 if (!WinSendMsg(hwndCnr, 599 617 CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) { … … 602 620 FreeCnrItem(hwndCnr, pci); 603 621 } 604 605 622 else 623 ok = TRUE; 606 624 } 607 625 } … … 652 670 653 671 HMTX hmtxFleshWork; 654 HEV 672 HEV hevFleshWorkListChanged; 655 673 656 674 /** … … 691 709 */ 692 710 693 694 711 BOOL AddFleshWorkRequest(HWND hwndCnr, PCNRITEM pci, FLESHWORKACTION action) 695 712 { … … 702 719 return FALSE; 703 720 704 705 721 xDosRequestMutexSem(hmtxFleshWork, SEM_INDEFINITE_WAIT); 706 722 … … 749 765 * @parse pszFileName is dependent pathName 750 766 */ 751 752 767 753 768 VOID WaitFleshWorkListEmpty(PCSZ pszDirName, ULONG ulSleep) … … 761 776 INT rcCount = 0; 762 777 763 if (tid == 1 || tid == tidFleshWorkListThread) { // 11 Oct 15 GKY Fixme did we intend to keep this 778 // 11 Oct 15 GKY FIXME did we intend to keep this 779 if (tid == 1 || tid == tidFleshWorkListThread) { 764 780 Runtime_Error(pszSrcFile, __LINE__, "WaitFleshWorkListEmpty called by tid %u", tid); 765 return; // Avoid hang781 return; // Avoid hang 766 782 } 767 783 // Can not wait if call from thread 1 or FleshWorkListThread … … 775 791 rc = xDosRequestMutexSem(hmtxFleshWork, SEM_INDEFINITE_WAIT); 776 792 if (rc) { 777 778 779 780 781 782 783 784 793 rcCount++; 794 if (rcCount < 6) 795 continue; // Maybe should return ??? 796 else { 797 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 798 PCSZ_DOSREQUESTMUTEXSEM); 799 return; 800 } 785 801 786 802 } … … 800 816 if (!item) { 801 817 if (waited) 802 818 DosSleep(ulSleep); // Let PM do some work 803 819 break; // Dependents gone from work list 804 820 } … … 871 887 if (!item) { 872 888 xfree((PSZ)pszFleshFocusPath, pszSrcFile, __LINE__); 873 pszFleshFocusPath = NULL; 889 pszFleshFocusPath = NULL; // Revert to normal 874 890 } 875 891 else … … 886 902 // Wait for new items to be added to list 887 903 if (!item) { 888 889 890 891 904 ULONG ul; 905 xDosWaitEventSem(hevFleshWorkListChanged, SEM_INDEFINITE_WAIT); 906 xDosResetEventSem(hevFleshWorkListChanged, &ul); 907 continue; 892 908 } 893 909 894 910 if (WinIsWindow((HAB)0, item->hwndCnr)) { 895 911 896 912 switch (item->action) { 897 898 913 case eUnFlesh: 914 UnFlesh(item->hwndCnr, item->pci); 899 915 break; 900 916 case eFleshEnv: … … 902 918 break; 903 919 case eStubby: 904 905 906 920 priority_bumped(); 921 Stubby(item->hwndCnr, item->pci); 922 priority_normal(); 907 923 break; 908 924 case eFlesh: … … 915 931 } // switch 916 932 917 918 933 } // if window 919 934
Note:
See TracChangeset
for help on using the changeset viewer.