Changeset 1444 for trunk/dll/treecnr.c


Ignore:
Timestamp:
Jul 23, 2009, 1:24:23 AM (16 years ago)
Author:
Gregg Young
Message:

Rework of drivebar to rescan all drives and refresh media buttons and menu items grey out inappropriate menu items. Streamline Tree scan code and use semaphores to serialize access. Add NOEASUPPORT and LOCALHD driveflag; .LONGNAME usage fixes; (Tickets 377-386)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/treecnr.c

    r1439 r1444  
    7272  12 Jul 09 GKY Add option to show file system type or drive label in tree
    7373                (get NOPRESCAN drives working)
     74  22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning
     75  22 Jul 09 GKY Consolidated driveflag setting code in DriveFlagsOne
     76  22 Jul 09 GKY Streamline scanning code for faster Tree rescans
    7477
    7578***********************************************************************/
     
    629632      Fortify_BecomeOwner(mp1);
    630633#     endif
    631       if (StubbyScanCount != 0) { //prevent treeswitch from hanging fm2 during startup GKY 3-14-09
    632         DosSleep(50);
    633         PostMsg(hwndTree, UM_SHOWME, mp1, MPVOID);
    634       }
    635634      dcd = INSTDATA(hwnd);
    636635      if (dcd) {
     
    644643          temptop = fTopDir;
    645644          fTopDir = TRUE;
    646         }
    647         ShowTreeRec(dcd->hwndCnr, (CHAR *)mp1, fCollapseFirst, TRUE);
     645        }
     646        ShowTreeRec(dcd->hwndCnr, (CHAR *)mp1, fCollapseFirst, TRUE);
     647        PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_UPDATE, 0), MPVOID);
    648648        dcd->suspendview = tempsusp;
    649649        fFollowTree = tempfollow;
     
    849849      Runtime_Error(pszSrcFile, __LINE__, NULL);
    850850    else {
    851       while (StubbyScanCount != 0)
    852         DosSleep(50);
    853851      RemoveCnrItems(dcd->hwndCnr, NULL, 0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
    854852      WinSendMsg(dcd->hwndCnr,
     
    856854      WinSendMsg(dcd->hwndCnr,
    857855                 CM_SCROLLWINDOW,
    858                  MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(-1));
     856                 MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(-1));
     857      DosRequestMutexSem(hmtFillingTreeCnr, SEM_INDEFINITE_WAIT);
    859858      FillTreeCnr(dcd->hwndCnr, dcd->hwndParent);
     859      DosReleaseMutexSem(hmtFillingTreeCnr);
    860860      if (fOkayMinimize) {
    861861        PostMsg(dcd->hwndCnr, UM_MINIMIZE, MPVOID, MPVOID);
     
    10931093        WinSetWindowText(hwndStatus2, NullStr);
    10941094    }
     1095    // 13 Jul 09 SHL fixme to make sense
    10951096    if (msg == UM_TIMER)
    10961097      return 0;
     
    18871888      PCNRITEM pciP, pciL, pci;
    18881889      ULONG fl = SWP_ACTIVATE;
    1889 
     1890      INT x;
     1891
     1892      DosRequestMutexSem(hmtFillingTreeCnr, SEM_INDEFINITE_WAIT);
    18901893      if (fFollowTree)
    18911894        fl = 0;
     
    18951898          (INT) pci != -1 &&
    18961899          !(pci->rc.flRecordAttr & CRA_INUSE) &&
    1897           !(pci->flags & RECFLAGS_ENV) && IsFullName(pci->pszFileName)) {
    1898         if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_INVALID) {
     1900          !(pci->flags & RECFLAGS_ENV) && IsFullName(pci->pszFileName)) {
     1901        x = (INT) (toupper(*pci->pszFileName) - 'A');
     1902        if (driveflags[x] & DRIVE_INVALID) {
    18991903          if (!fAlertBeepOff)
    19001904            DosBeep(50, 100);
     
    19051909        DosError(FERR_DISABLEHARDERR);
    19061910        if (!DosQCurDisk(&ulDriveNum, &ulDriveMap)) {
    1907           if (!(ulDriveMap & 1 << (toupper(*pci->pszFileName) - 'A'))) {
     1911          if (!(ulDriveMap & 1 << x)) {
    19081912            pciL = pciP = pci;
    19091913            for (;;) {
     
    19231927          }
    19241928        }
    1925         if (driveflags[toupper(*pci->pszFileName) - 'A'] &
    1926             (DRIVE_REMOVABLE | DRIVE_NOPRESCAN)) {
     1929        if (driveflags[x] & (DRIVE_REMOVABLE | DRIVE_NOPRESCAN)) {
    19271930
    19281931          struct
     
    19491952            }
    19501953          }
    1951           if ((driveflags[toupper(*pci->pszFileName) - 'A'] &
    1952                DRIVE_NOPRESCAN) ||
    1953               (toupper(*pci->pszFileName) > 'B' &&
    1954                !(driveflags[toupper(*pci->pszFileName) - 'A'] &
    1955                  DRIVE_CDROM))) {
    1956 
    1957             INT removable, x = (INT) (toupper(*pci->pszFileName) - 'A');
    1958             ULONG drvtype;
    1959 
    1960             DosError(FERR_DISABLEHARDERR);
    1961             removable = CheckDrive(toupper(*pciP->pszFileName),
    1962                                    FileSystem, &drvtype);
    1963             if (removable != -1) {
    1964               driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN |
    1965                                 DRIVE_NOLOADICONS | DRIVE_NOLOADSUBJS |
    1966                                 DRIVE_NOLOADLONGS | DRIVE_INCLUDEFILES |
    1967                                 DRIVE_SLOW | DRIVE_NOSTATS |
    1968                                 DRIVE_WRITEVERIFYOFF);
    1969 
    1970               if (removable == 1)
    1971                 driveflags[x] |= DRIVE_REMOVABLE;
    1972               if (drvtype & DRIVE_REMOTE)
    1973                 driveflags[x] |= DRIVE_REMOTE;
    1974               if (!strcmp(FileSystem, CBSIFS)) {
    1975                 driveflags[x] |= DRIVE_ZIPSTREAM;
    1976                 driveflags[x] &= (~DRIVE_REMOTE);
    1977               }
    1978               if(!strcmp(FileSystem,NDFS32)) {
    1979                 driveflags[x] |= DRIVE_VIRTUAL;
    1980                 driveflags[x] &= (~DRIVE_REMOTE);
    1981               }
    1982               if(!strcmp(FileSystem,RAMFS)) {
    1983                 driveflags[x] |= DRIVE_RAMDISK;
    1984                 driveflags[x] &= (~DRIVE_REMOTE);
    1985               }
    1986               if (!strcmp(FileSystem, CDFS) || !strcmp(FileSystem, ISOFS))
    1987                 driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE | DRIVE_CDROM);
    1988               if(!strcmp(FileSystem,NTFS))
    1989                 driveflags[x] |= DRIVE_NOTWRITEABLE;
    1990               if (strcmp(FileSystem, HPFS) &&
    1991                   strcmp(FileSystem, JFS) &&
    1992                   strcmp(FileSystem, CDFS) &&
    1993                   strcmp(FileSystem, ISOFS) &&
    1994                   strcmp(FileSystem, RAMFS) &&
    1995                   strcmp(FileSystem, FAT32) &&
    1996                   strcmp(FileSystem, NDFS32) &&
    1997                   strcmp(FileSystem, NTFS) &&
    1998                   strcmp(FileSystem, HPFS386)) {
    1999                 driveflags[x] |= DRIVE_NOLONGNAMES;
    2000               }
    2001               SelectDriveIcon(pciP);
    2002               if (hwndMain)
    2003                 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
    2004             }
     1954          if ((driveflags[x] & DRIVE_NOPRESCAN) || (toupper(*pci->pszFileName) > 'B' &&
     1955               !(driveflags[x] & DRIVE_CDROM))) {
     1956            DriveFlagsOne(x, FileSystem, &volser);
     1957            SelectDriveIcon(pciP);
     1958            if (hwndMain)
     1959              PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
    20051960          }
    20061961          memset(&volser, 0, sizeof(volser));
     
    20101965                                  (ULONG) sizeof(volser));
    20111966          if (!status) {
    2012             if (!volser.serial ||
    2013                 driveserial[toupper(*pci->pszFileName) - 'A'] !=
    2014                 volser.serial) {
     1967            if (!volser.serial || driveserial[x] != volser.serial) {
    20151968              UnFlesh(hwnd, pciP);
    20161969              Flesh(hwnd, pciP);
    2017               driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
     1970              driveserial[x] = volser.serial;
    20181971            }
    20191972            pciL = WinSendMsg(hwnd,
     
    20231976            if (!pciL)
    20241977              Flesh(hwnd, pciP);
    2025             if (fShowFSTypeInTree) {
    2026               strcpy(szBuf, pciP->pszFileName);
     1978            if (fShowFSTypeInTree || fShowDriveLabelInTree) {
     1979              strcpy(szBuf, pci->pszFileName);
    20271980              strcat(szBuf, " [");
    2028               strcat(szBuf, FileSystem);
     1981              strcat(szBuf, fShowFSTypeInTree ? FileSystem : volser.volumelabel);
    20291982              strcat(szBuf, "]");
    2030               pciP->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
    2031               }
    2032             else if (fShowDriveLabelInTree) {
    2033               strcpy(szBuf, pciP->pszFileName);
    2034               strcat(szBuf, " [");
    2035               strcat(szBuf, volser.volumelabel);
    2036               strcat(szBuf, "]");
    2037               pciP->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
     1983              pci->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
    20381984            }
    20391985            pciP->rc.pszIcon = pciP->pszDisplayName;
     
    20441990          }
    20451991          else {
    2046             driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
     1992            driveserial[x] = -1;
    20471993            UnFlesh(hwnd, pci);
    20481994            PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     
    21202066          }
    21212067          else {
    2122             if (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
    2123                   DRIVE_INCLUDEFILES))
     2068            if (!(driveflags[x] & DRIVE_INCLUDEFILES))
    21242069              RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE);
    21252070            else {
     
    21442089        PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
    21452090      if (fFollowTree)
    2146         WinSetFocus(HWND_DESKTOP, hwnd);
     2091        WinSetFocus(HWND_DESKTOP, hwnd);
     2092      DosReleaseMutexSem(hmtFillingTreeCnr);
    21472093    }
    21482094    return 0;
     
    23672313
    23682314  case UM_DRIVECMD:
    2369     if (mp1)
     2315    if (mp1) {
    23702316      ShowTreeRec(hwnd, (CHAR *)mp1, FALSE, TRUE);
     2317      PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_UPDATE, 0), MPVOID);
     2318    }
    23712319    return 0;
    23722320
     
    23862334          *s = info->device;
    23872335          pci = FindCnrRecord(hwnd, s, NULL, FALSE, FALSE, TRUE);
    2388           if (pci && (INT) pci != -1) {
    2389             driveserial[info->device - 'A'] = -1;
    2390             DriveFlagsOne(info->device - 'A');
    2391             if (driveflags[info->device - 'A'] &
     2336          if (pci && (INT) pci != -1) {
     2337            INT x = info->device - 'A';
     2338            CHAR  FileSystem[CCHMAXPATH];
     2339
     2340            driveserial[x] = -1;
     2341            DriveFlagsOne(x, FileSystem, NULL);
     2342            if (driveflags[x] &
    23922343                (DRIVE_INVALID | DRIVE_IGNORE))
    23932344              RemoveCnrItems(hwnd, pci, 1, CMA_FREE);
     
    27892740
    27902741      case IDM_UPDATE:
    2791         {
     2742        {
    27922743          PCNRITEM pci = (PCNRITEM)CurrentRecord(hwnd);
    2793           if (pci && (INT)pci != -1) {
    2794             UINT driveflag = driveflags[toupper(*pci->pszFileName) - 'A'];
     2744          if (pci && (INT)pci != -1) {
     2745            struct
     2746            {
     2747              ULONG serial;
     2748              CHAR volumelength;
     2749              CHAR volumelabel[CCHMAXPATH];
     2750            }
     2751            volser;
     2752            INT x = toupper(*pci->pszFileName) - 'A';
     2753            CHAR FileSystem[CCHMAXPATH], szBuf[CCHMAXPATH];
     2754
     2755            UINT driveflag = driveflags[x];
    27952756            if (pci->attrFile & FILE_DIRECTORY) {
    27962757              if (pci->flags & RECFLAGS_UNDERENV)
    2797                 break;
     2758                break;
     2759              DosRequestMutexSem(hmtFillingTreeCnr, SEM_INDEFINITE_WAIT);
    27982760              UnFlesh(hwnd, pci);
    27992761              // Check if drive type might need update
    28002762              if ((driveflag & (DRIVE_INVALID | DRIVE_NOPRESCAN)) ||
    2801                   (~driveflag & DRIVE_NOPRESCAN && pci->rc.hptrIcon == hptrDunno))
    2802               {
    2803                 driveflags[toupper(*pci->pszFileName) - 'A'] &=
    2804                   (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS |
    2805                    DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS | DRIVE_NOSTATS |
    2806                    DRIVE_WRITEVERIFYOFF);
    2807                 DriveFlagsOne(toupper(*pci->pszFileName) - 'A');
    2808                 driveflag = driveflags[toupper(*pci->pszFileName) - 'A'];
     2763                  (~driveflag & DRIVE_NOPRESCAN && pci->rc.hptrIcon == hptrDunno)) {
     2764                DriveFlagsOne(x, FileSystem, &volser);
     2765                driveflag = driveflags[x];
    28092766                if (driveflag & DRIVE_INVALID)
    28102767                  pci->rc.hptrIcon = hptrDunno;
    28112768                else {
    28122769                  SelectDriveIcon(pci);
    2813                 }
     2770                }
     2771                if (fShowFSTypeInTree || fShowDriveLabelInTree) {
     2772                  strcpy(szBuf, pci->pszFileName);
     2773                  strcat(szBuf, " [");
     2774                  strcat(szBuf, fShowFSTypeInTree ? FileSystem : volser.volumelabel);
     2775                  strcat(szBuf, "]");
     2776                  pci->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
     2777                }
     2778                pci->rc.pszIcon = pci->pszDisplayName;
    28142779                WinSendMsg(hwnd,
    28152780                           CM_INVALIDATERECORD,
     
    28202785              }
    28212786              if (~driveflag & DRIVE_INVALID)
    2822                 Flesh(hwnd, pci);
     2787                Flesh(hwnd, pci);
     2788              DosReleaseMutexSem(hmtFillingTreeCnr);
    28232789            }
    28242790          }
     
    30292995    return 0;
    30302996
     2997  case WM_TIMER:
     2998    return ActionWMTimer(hwnd, mp1, mp2);
     2999
    30313000  case WM_SAVEAPPLICATION:
    30323001    if (dcd && !ParentIsDesktop(hwnd, dcd->hwndParent)) {
     
    32603229                                     NULL,
    32613230                                     CCS_AUTOPOSITION | CCS_MINIICONS |
    3262                                      CCS_MINIRECORDCORE, //| WS_VISIBLE,
     3231                                     CCS_MINIRECORDCORE,
    32633232                                     0,
    32643233                                     0,
     
    32793248        if (ParentIsDesktop(hwndFrame, hwndParent)) {
    32803249          WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR), "VTree");
    3281           FixSwitchList(hwndFrame, "VTree");
     3250          FixSwitchList(hwndFrame, "VTree");
     3251          DosPostEventSem(hevInitialCnrScanComplete);
     3252          DosCloseEventSem(hevInitialCnrScanComplete);
     3253          fInitialDriveScan = FALSE;
    32823254        }
    32833255        else {
Note: See TracChangeset for help on using the changeset viewer.