Changeset 1871 for trunk/dll/flesh.c


Ignore:
Timestamp:
Sep 21, 2015, 12:57:02 AM (10 years ago)
Author:
Gregg Young
Message:

Create CollapseAll and modify ExpandAll to reduce code overhead both to try and speed drive expansion. Change ExpandAll to allow it to loop in UM_EXPAND until until drive is completely expanded. Changes were need to work with Flesh, Stubby and UnFlesh being moved to a thread. Add code for Flesh to skip the directory entry added by Stubby (eliminate use of NULL/Nullstr pszFileNames by Stubby). Add code in Stubby to insert a complete container item. Add a flag to indicate when a directory needed to be Fleshed. Get expand and switch code to work with Flesh, UnFlesh and Stubby running on a thread. Loop and idle ExpandAll; Move tree expand to a thread; Have ShowTreeRec wait for the Flesh thread. Add a correction factor so directories don't get placed above the top of the tree container when a large drive has been expanded. Debug is mostly still in but all turned off.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/flesh.c

    r1867 r1871  
    3737  19 Aug 15 SHL Allow WaitFleshWorkListEmpty to wait for dependent items
    3838  23 Aug 15 GKY Fixed code to notify on drive with no subdirectories in first 64 entries
     39  20 Sep 15 GKY Add code for Flesh to skip the directory entry added by Stubby (eliminate
     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
    3943
    4044***********************************************************************/
     
    6973#include "listutil.h"                   // List...
    7074#include "common.h"                     // IncrThreadUsage DecrThreadUsage
    71 
     75#include "pathutil.h"
    7276#if 0
    7377#define  __PMPRINTF__
     
    8488
    8589static PCSZ pszFleshFocusPath;  // 2015-08-20 SHL
    86 
     90#if 0
    8791BOOL fNoFleshDbgMsg;    // 2015-08-09 SHL FIXME to be gone
    88 
     92#endif
    8993#pragma data_seg(GLOBAL1)
    9094ULONG NoBrokenNotify;
     
    189193                ri.cRecordsInsert = 1;
    190194                ri.fInvalidateRecord = FALSE;
    191                 // 2015-08-03 SHL FIXME debug
     195#if 0           // 2015-08-03 SHL FIXME debug
    192196                if (pciL->pszFileName == NullStr)
    193197                  DbgMsg(pszSrcFile, __LINE__, "Stubby CM_INSERTRECORD pci %p pszFileName \"%s\"", pciL, pciL->pszFileName); // 2015-08-03 SHL FIXME debug
    194                 if (!WinSendMsg(hwndCnr,
     198#endif
     199                if (!WinSendMsg(hwndCnr,
    195200                                CM_INSERTRECORD, MPFROMP(pciL), MPFROMP(&ri)))
    196201                  FreeCnrItem(hwndCnr, pciL);
     
    238243    return FALSE;
    239244
    240   // 2015-08-03 SHL FIXME debug
     245#if 0  // 2015-08-03 SHL FIXME debug
    241246  if (!fNoFleshDbgMsg) {
    242247    DbgMsg(pszSrcFile, __LINE__, "Flesh %s pciParent %p pszFileName %p",
     
    246251           pciParent && (INT)pciParent != -1 ? pciParent->pszFileName : (PVOID)-1); // 2015-08-03 SHL FIXME debug
    247252  }
    248 
    249   pciL = (PCNRITEM)WinSendMsg(hwndCnr,
    250                               CM_QUERYRECORD,
    251                               MPFROMP(pciParent),
    252                               MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    253 
     253#endif
    254254  // 2015-08-06 SHL allow pciL -1
    255255  // 2015-08-06 SHL FIXME to not need pszFileName check
    256   if (!pciL || (INT)pciL == -1 || !*pciL->pszFileName || !strcmp(pciL->pszFileName, NullStr)) {
    257 
     256  if (!pciParent->fleshed) {
     257    pciL = (PCNRITEM)WinSendMsg(hwndCnr,
     258                                CM_QUERYRECORD,
     259                                MPFROMP(pciParent),
     260                                MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    258261    // No children or filename null
    259262    if (pciL && (INT)pciL != -1) {
     263      AddFleshWorkRequest(hwndCnr, pciL, eStubby);
    260264      // 2015-08-06 SHL FIXME to ensure this an not happen
    261       // if (!*pciL->pszFileName)
    262         // Runtime_Error(pszSrcFile, __LINE__, "Flesh called with pci %p pszFileName (null)", pciL);
    263 
     265      if (!*pciL->pszFileName || !strcmp(pciL->pszFileName, NullStr))
     266        Runtime_Error(pszSrcFile, __LINE__, "Flesh called with pci %p pszFileName (null)", pciL);
     267#if 0
    264268      if (!fNoFleshDbgMsg)
    265269        DbgMsg(pszSrcFile, __LINE__, "Flesh RemoveCnrItems() pciL %p \"%s\"",
     
    267271               pciL->pszFileName ? pciL->pszFileName : "(null)"); // 2015-08-04 SHL FIXME debug
    268272      // Assume refernces to pciL already removed from work list
    269       RemoveCnrItems(hwndCnr, pciL, 1, CMA_FREE);
    270     }
    271 
     273#endif
     274    }
    272275    dcd = INSTDATA(hwndCnr);
    273276    if (dcd && dcd->size != sizeof(DIRCNRDATA))
     
    287290                     dcd,
    288291                     NULL,              // total files
    289                      NULL);             // total bytes
     292                     NULL,               // total bytes
     293                     (pciL && (INT)pciL != -1) ? pciL->pszDisplayName : 0);
     294    pciParent->fleshed = TRUE;
    290295    return TRUE;
    291296  }
     
    306311  if (!pciParent || !hwndCnr)
    307312    return;
    308 
     313#if 0
    309314  if (!fNoFleshDbgMsg)
    310315    DbgMsg(pszSrcFile, __LINE__, "UnFlesh pciParent %p pszFileName \"%s\"", pciParent, pciParent->pszFileName ? pciParent->pszFileName : "(null)"); // 2015-08-03 SHL FIXME debug
    311 
     316#endif
    312317  for (;;) {
    313318    pciL = (PCNRITEM)WinSendMsg(hwndCnr,
     
    317322    if (!pciL || (INT)pciL == -1)
    318323      break;                    // Done
    319 
     324#if 0
    320325    if (!fNoFleshDbgMsg)
    321326      DbgMsg(pszSrcFile, __LINE__, "UnFlesh RemoveCnrItems() pciL %p \"%s\"", pciL, pciL->pszFileName ? pciL->pszFileName : "(null)"); // 2015-08-03 SHL FIXME debug
     327#endif
    322328    RemoveCnrItems(hwndCnr, pciL, 1, CMA_FREE);
    323329    removed = TRUE;
     
    328334               CM_INVALIDATERECORD,
    329335               MPFROMP(&pciParent),
    330                MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
     336               MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
     337    pciParent->fleshed = FALSE;
     338    DosSleep(1); // Let container items go away
    331339  }
    332340  return;
     
    368376  static BOOL brokenlan = FALSE, isbroken = FALSE;
    369377
     378  //DbgMsg(pszSrcFile, __LINE__,"Stubby pciParent %p", pciParent);
    370379  if (!pciParent || (INT)pciParent == -1 || !*pciParent->pszFileName
    371380      || pciParent->pszFileName == NullStr || !hwndCnr)
    372381    return FALSE;
    373 
     382#if 0
    374383  if (!fNoFleshDbgMsg)
    375384    DbgMsg(pszSrcFile, __LINE__, "Stubby pciParent %p pszFileName %s", pciParent, pciParent->pszFileName); // 2015-08-03 SHL FIXME debug
    376 
     385#endif
    377386  // Build wildcard
    378387  len = strlen(pciParent->pszFileName);
     
    386395  if (!isalpha(*wildcard) || wildcard[1] != ':' || wildcard[2] != '\\') {
    387396    MakeFullName(wildcard);
    388     DbgMsg(pszSrcFile, __LINE__, "Stubby MakeFullName returned %s", wildcard); // 2015-08-19 SHL FIXME debug
    389   }
    390 
     397    //DbgMsg(pszSrcFile, __LINE__, "Stubby MakeFullName returned %s", wildcard); // 2015-08-19 SHL FIXME debug
     398  }
    391399  drvNum = toupper(*pciParent->pszFileName) - 'A';
    392400  flags = driveflags[drvNum];
     
    421429  fl = includefiles ? FILE_DIRECTORY : MUST_HAVE_DIRECTORY;
    422430
    423   DbgMsg(pszSrcFile, __LINE__, "Stubby DosFindFirst(%s)", wildcard); // 2015-08-19 SHL FIXME debug
     431  //DbgMsg(pszSrcFile, __LINE__, "Stubby DosFindFirst(%s)", wildcard); // 2015-08-19 SHL FIXME debug
    424432
    425433  rc = DosFindFirst(wildcard,
     
    495503    goto None;                          // Done
    496504  }
    497 
    498 
    499505  if (!rc) {
    500506    DosFindClose(hDir);
     
    539545              (pffb->achName[1] != '.' || pffb->achName[2]))))
    540546        {
    541           // Got directory other than . or .. (or a file)
     547          // Got directory other than . or .. (or a file)
    542548          isadir = TRUE;
    543549          break;
     
    562568          }
    563569          else {
    564             RECORDINSERT ri;
    565             // 2015-08-19 SHL FIXME to use BldFullPathName(wildcard, ...)
    566             pci->pszFileName = NullStr; // 2015-08-19 SHL FIXME to doc why
    567             pci->pszDisplayName = NullStr;
    568             pci->rc.pszIcon = pci->pszDisplayName;
     570            RECORDINSERT ri;
     571            CHAR szBuffer[CCHMAXPATH + 14];
     572            CHAR *p;
     573            HPOINTER hptr;
     574
     575            p = strchr(wildcard, '*');
     576            *p = 0;;
     577            BldFullPathName(szBuffer, wildcard, pffb->achName);
     578            pci->pszFileName =  xstrdup(szBuffer, pszSrcFile, __LINE__); //NullStr;   // 2015-08-19 SHL FIXME to doc why
     579            p = strrchr(pci->pszFileName, '\\');
     580            p++;
     581            pci->pszDisplayName = p; //NullStr;
     582            pci->rc.pszIcon = pci->pszDisplayName;
     583            if (fForceUpper)
     584              strupr(pci->pszFileName);
     585            else if (fForceLower)
     586              strlwr(pci->pszFileName);
     587         
     588            flags = driveflags[toupper(*pci->pszFileName) - 'A'];
     589         
     590            // get an icon to use with it
     591            if (pffb->attrFile & FILE_DIRECTORY) {
     592              // is directory
     593              if (fNoIconsDirs ||
     594                  (flags & DRIVE_NOLOADICONS) ||
     595                  !isalpha(*pci->pszFileName)) {
     596                hptr = (HPOINTER) 0;
     597              }
     598              else
     599                hptr = WinLoadFileIcon(pci->pszFileName, FALSE);
     600            }
     601            else {
     602              // is file
     603              if (fNoIconsFiles ||
     604                  (flags & DRIVE_NOLOADICONS) ||
     605                  !isalpha(*pci->pszFileName)) {
     606                hptr = (HPOINTER) 0;
     607              }
     608              else
     609                hptr = WinLoadFileIcon(pci->pszFileName, FALSE);
     610         
     611              if (!hptr || IsDefaultIcon(hptr))
     612                hptr = IDFile(pci->pszFileName);
     613            }
     614         
     615            if (!hptr) {
     616              hptr = pffb->attrFile & FILE_DIRECTORY ?
     617                     hptrDir : pffb->attrFile & FILE_SYSTEM ?
     618                     hptrSystem : pffb->attrFile & FILE_HIDDEN ?
     619                     hptrHidden : pffb->attrFile & FILE_READONLY ?
     620                     hptrReadonly : hptrFile;
     621            }
     622            pci->rc.hptrIcon = hptr;
    569623            memset(&ri, 0, sizeof(RECORDINSERT));
    570624            ri.cb = sizeof(RECORDINSERT);
     
    574628            ri.cRecordsInsert = 1;
    575629            ri.fInvalidateRecord = TRUE;
    576              // 2015-08-03 SHL FIXME debug
     630#if 0        // 2015-08-03 SHL FIXME debug
    577631            if (pci->pszFileName == NullStr)
    578632              DbgMsg(pszSrcFile, __LINE__, "Stubby CM_INSERTRECORD %p \"%s\" %.255s", pci, pci->pszFileName, pffb->achName);
    579             if (!WinSendMsg(hwndCnr,
     633#endif
     634            if (!WinSendMsg(hwndCnr,
    580635                            CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
    581636              // Assume busy and try again
    582637              DosSleep(50); //05 Aug 07 GKY 100
    583638              WinSetFocus(HWND_DESKTOP, hwndCnr);
    584               if (WinIsWindow((HAB)0, hwndCnr)) {
     639              if (WinIsWindow((HAB)0, hwndCnr)) {
     640#if 0
    585641                if (!fNoFleshDbgMsg) {
    586                   // 2015-08-03 SHL FIXME debug
    587                   if (pci->pszFileName == NullStr)
    588                     DbgMsg(pszSrcFile, __LINE__, "Stubby CM_INSERTRECORD pci %p pszFileName \"%s\"", pci, pci->pszFileName); // 2015-08-03 SHL FIXME debug
    589                 }
     642                  // 2015-08-03 SHL FIXME debug
     643                  //if (pci->pszFileName == NullStr)
     644                  //  DbgMsg(pszSrcFile, __LINE__, "Stubby CM_INSERTRECORD pci %p pszFileName \"%s\"", pci, pci->pszFileName); // 2015-08-03 SHL FIXME debug
     645                }
     646#endif
    590647                if (!WinSendMsg(hwndCnr,
    591648                                CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
     
    594651                  FreeCnrItem(hwndCnr, pci);
    595652                }
    596                 else
     653                else
    597654                  ok = TRUE;
    598655              }
     
    670727    if (!item)
    671728      break;
    672     DbgMsg(pszSrcFile, __LINE__, "DeleteStaleFleshWorkListItems deleting %p %s", pci, pci->pszFileName ? pci->pszFileName : "(null)"); // 2015-08-03 SHL FIXME debug
     729    //DbgMsg(pszSrcFile, __LINE__, "DeleteStaleFleshWorkListItems deleting %p %s", pci, pci->pszFileName ? pci->pszFileName : "(null)"); // 2015-08-03 SHL FIXME debug
    673730    List2Delete(&FleshWorkList, item);
    674731    xfree(item, pszSrcFile, __LINE__);
     
    815872    return;             // Avoid hang
    816873  }
     874#if 0
    817875  else if (IsFleshWorkListEmpty()) {
    818876#   ifdef WaitFleshWorkListEmpty
     
    822880#   endif
    823881  }
     882#endif
    824883
    825884  // Can not wait if call from thread 1 or FleshWorkListThread
     
    859918      if (!item) {
    860919        if (waited)
    861           DosSleep(250);                // Let PM do some work
     920          DosSleep(100);                // Let PM do some work
    862921        break;                          // Dependents gone from work list
    863922      }
     
    889948  if (pszOld)
    890949    xfree((PVOID)pszOld, pszSrcFile, __LINE__);
    891   DbgMsg(pszSrcFile, __LINE__, "SetFleshFocusPath focus path set to %s", pszFleshFocusPath); // 2015-08-03 SHL FIXME debug
     950  //DbgMsg(pszSrcFile, __LINE__, "SetFleshFocusPath focus path set to %s", pszFleshFocusPath); // 2015-08-03 SHL FIXME debug
    892951
    893952}
     
    9481007        // Wait for new items to be added to list
    9491008        if (!item) {
    950           ULONG ul;
     1009          ULONG ul;
     1010#if 0
    9511011          if (!fNoFleshDbgMsg)
    9521012            DbgMsg(pszSrcFile, __LINE__, "FleshWorkThread work list empty - waiting"); // 2015-08-03 SHL FIXME debug
    953           xDosWaitEventSem(hevFleshWorkListChanged, SEM_INDEFINITE_WAIT);
    954           xDosResetEventSem(hevFleshWorkListChanged, &ul);
     1013#endif
     1014          xDosWaitEventSem(hevFleshWorkListChanged, SEM_INDEFINITE_WAIT);
     1015          xDosResetEventSem(hevFleshWorkListChanged, &ul);
     1016#if 0
    9551017          if (!fNoFleshDbgMsg)
    9561018            DbgMsg(pszSrcFile, __LINE__, "FleshWorkThread work hev posted"); // 2015-08-03 SHL FIXME debug
    957           continue;
     1019#endif
     1020          continue;
    9581021        }
    9591022
    960         if (WinIsWindow((HAB)0, item->hwndCnr)) {
    961 #if 0 // 2015-08-07 SHL FIXME debug
    962           // 2015-08-03 SHL FIXME debug
     1023        if (WinIsWindow((HAB)0, item->hwndCnr)) {
     1024#if 0     // 2015-08-07 SHL FIXME debug
    9631025          {
    9641026            static PSZ itemNames[] = {
     
    9791041
    9801042          switch (item->action) {
    981           case eUnFlesh:
    982             UnFlesh(item->hwndCnr, item->pci);
     1043          case eUnFlesh:
     1044            UnFlesh(item->hwndCnr, item->pci);
    9831045            break;
    9841046          case eFleshEnv:
     
    9871049          case eStubby:
    9881050            // DbgMsg(pszSrcFile, __LINE__, "FleshWorkThread pci %p pszFileName %s", stubbyArgs->pci, stubbyArgs->pci->pszFileName); // 2015-08-03 SHL FIXME debug
    989             Stubby(item->hwndCnr, item->pci);
     1051            priority_bumped();
     1052            Stubby(item->hwndCnr, item->pci);
     1053            priority_normal();
    9901054            break;
    9911055          case eFlesh:
     
    10411105  if (rc)
    10421106    return FALSE;                       // Give up
    1043 
    1044   /* DbgMsg is time consuming
     1107#if 0
     1108   /*DbgMsg is time consuming
    10451109     define FM2_NO_FLESH_DBGMSG to suppress
    10461110     2015-08-09 SHL FIXME to be gone
    1047    */
     1111     */
    10481112
    10491113  fNoFleshDbgMsg = getenv("FM2_NO_FLESH_DBGMSG") != NULL;
    1050 
     1114#endif
    10511115  tidFleshWorkListThread = xbeginthread(FleshWorkThread,
    10521116                           65536,
Note: See TracChangeset for help on using the changeset viewer.