Changeset 150 for trunk/dll/dircnrs.c


Ignore:
Timestamp:
May 26, 2005, 3:58:27 AM (20 years ago)
Author:
root
Message:

Comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/dircnrs.c

    r145 r150  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2005 Steven H.Levine
     9  Copyright (c) 2001, 2005 Steven H. Levine
    1010
    1111  16 Oct 02 SHL Handle large partitions
     
    1313  23 May 05 SHL Use QWL_USER
    1414  24 May 05 SHL Rework Win_Error usage
     15  25 May 05 SHL Use ULONGLONG and CommaFmtULL
    1516
    1617***********************************************************************/
     
    2021#define INCL_GPI
    2122#define INCL_DOSERRORS
     23#define INCL_LONGLONG
    2224
    2325#include <os2.h>
     
    630632
    631633
    632 MRESULT EXPENTRY DirObjWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    633 
     634MRESULT EXPENTRY DirObjWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     635{
    634636  DIRCNRDATA *dcd;
    635637
     
    699701
    700702        FSALLOCATE fsa;
    701         CHAR       s[CCHMAXPATH * 2],tf[81],tb[81],fbytes[81];
     703        CHAR       s[CCHMAXPATH * 2],tf[81],tb[81],szBuf[81];
    702704
    703705        DosError(FERR_DISABLEHARDERR);
    704706        if(!DosQueryFSInfo(toupper(*dcd->directory) - '@',
    705707           FSIL_ALLOC,&fsa,sizeof(FSALLOCATE))) {
    706           strcpy(fbytes,"  {");
    707           commafmt(fbytes + 3,sizeof(fbytes) - 5,
    708                    (ULONG)(((float)fsa.cUnitAvail *
    709                      (fsa.cSectorUnit * fsa.cbSector)) / 1024L));
    710           strcat(fbytes,GetPString(IDS_KFREETEXT));
    711           strcat(fbytes,"}");
     708          strcpy(szBuf,"  {");
     709          CommaFmtULL(szBuf + 3,sizeof(szBuf) - 5,
     710                      (ULONGLONG)fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector),
     711                      'K');
     712          strcat(szBuf,GetPString(IDS_KFREETEXT));
     713          strcat(szBuf,"}");
    712714        }
    713715        else
    714           *fbytes = 0;
     716          *szBuf = 0;
    715717        commafmt(tf,sizeof(tf),dcd->totalfiles);
    716         commafmt(tb,sizeof(tb),dcd->totalbytes);
     718        CommaFmtULL(tb,sizeof(tb),dcd->ullTotalBytes,' ');
    717719        if(!fMoreButtons)
    718720          sprintf(s," [%s / %sb]%s%s%s%s %s",tf,tb,
    719                   fbytes,
     721                  szBuf,
    720722                  (*dcd->mask.szMask || dcd->mask.antiattr ||
    721723                   dcd->mask.attrFile != ALLATTRS) ? "  (" : NullStr,
     
    728730                  dcd->directory);
    729731        else
    730           sprintf(s," [%s / %sb]%s %s",tf,tb,fbytes,
     732          sprintf(s," [%s / %sb]%s %s",tf,tb,szBuf,
    731733                  dcd->directory);
    732734        if(dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent))
     
    810812                               dcd->directory,
    811813                               dcd);
    812         dcd->totalbytes = dcd->totalfiles =
     814        dcd->ullTotalBytes = dcd->totalfiles =
    813815          dcd->selectedfiles = dcd->selectedbytes = 0;
    814816        WinSetDlgItemText(dcd->hwndClient,
     
    844846        }
    845847        dcd->firsttree = FALSE;
    846         dcd->totalbytes = FillDirCnr(dcd->hwndCnr,
    847                                      dcd->directory,
    848                                      dcd);
     848        // fixme to check errors
     849        FillDirCnr(dcd->hwndCnr,
     850                   dcd->directory,
     851                   dcd,
     852                   &dcd->ullTotalBytes);
    849853        PostMsg(dcd->hwndCnr,
    850854                UM_RESCAN,
     
    12581262          case '\n':
    12591263            dcd->lasttime = 0;
    1260             *dcd->comnam = 0;
     1264            *dcd->szCommonName = 0;
    12611265            break;
    12621266          default:
    12631267            thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
    12641268            if(thistime > dcd->lasttime + 1250)
    1265               *dcd->comnam = 0;
     1269              *dcd->szCommonName = 0;
    12661270            dcd->lasttime = thistime;
    1267             if(SHORT1FROMMP(mp2) == ' ' && !dcd->comnam)
     1271            if(SHORT1FROMMP(mp2) == ' ' && !dcd->szCommonName)
    12681272              break;
    12691273KbdRetry:
    1270             len = strlen(dcd->comnam);
     1274            len = strlen(dcd->szCommonName);
    12711275            if(len >= CCHMAXPATH - 1) {
    1272               *dcd->comnam = 0;
     1276              *dcd->szCommonName = 0;
    12731277              len = 0;
    12741278            }
    1275             dcd->comnam[len] = toupper(SHORT1FROMMP(mp2));
    1276             dcd->comnam[len + 1] = 0;
     1279            dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
     1280            dcd->szCommonName[len + 1] = 0;
    12771281            memset(&srch,0,sizeof(SEARCHSTRING));
    12781282            srch.cb = (ULONG)sizeof(SEARCHSTRING);
    1279             srch.pszSearch = (PSZ)dcd->comnam;
     1283            srch.pszSearch = (PSZ)dcd->szCommonName;
    12801284            srch.fsPrefix = TRUE;
    12811285            srch.fsCaseSensitive = FALSE;
     
    12881292
    12891293              /* make found item current item */
    1290               if(!stricmp(pci->pszFileName,dcd->comnam))
     1294              if(!stricmp(pci->pszFileName,dcd->szCommonName))
    12911295                attrib |= CRA_SELECTED;
    12921296              WinSendMsg(hwnd,CM_SETRECORDEMPHASIS,MPFROMP(pci),
     
    12981302            else {
    12991303              if(SHORT1FROMMP(mp2) == ' ') {
    1300                 dcd->comnam[len] = 0;
     1304                dcd->szCommonName[len] = 0;
    13011305                break;
    13021306              }
    1303               *dcd->comnam = 0;
     1307              *dcd->szCommonName = 0;
    13041308              dcd->lasttime = 0;
    13051309              if(len)           // retry as first letter if no match
     
    15051509        dcd->totalfiles = cnri.cRecords;
    15061510        commafmt(tb,sizeof(tb),dcd->totalfiles);
    1507         if(dcd->totalbytes < 1024)
    1508           commafmt(tf,sizeof(tf),dcd->totalbytes);
    1509         else
    1510           commafmt(tf,sizeof(tf),dcd->totalbytes / 1024L);
    1511         sprintf(s,"%s / %s%s",tb,tf,(dcd->totalbytes < 1024) ? "b" : "k");
     1511        CommaFmtULL(tf,sizeof(tf),dcd->ullTotalBytes,'K');
     1512        sprintf(s,"%s / %s",tb,tf);
    15121513        WinSetDlgItemText(dcd->hwndClient,DIR_TOTALS,s);
    15131514        commafmt(tb,sizeof(tb),dcd->selectedfiles);
    1514         if(dcd->selectedbytes < 1024)
    1515           commafmt(tf,sizeof(tf),dcd->selectedbytes);
    1516         else
    1517           commafmt(tf,sizeof(tf),dcd->selectedbytes / 1024L);
    1518         sprintf(s,"%s / %s%s",tb,tf,(dcd->selectedbytes < 1024) ? "b" : "k");
     1515        CommaFmtULL(tf,sizeof(tf),dcd->selectedbytes,'K');
     1516        sprintf(s,"%s / %s",tb,tf);
    15191517        WinSetDlgItemText(dcd->hwndClient,DIR_SELECTED,s);
    15201518        if(hwndStatus &&
     
    15311529                             MPFROMLONG(CMA_FIRST),
    15321530                             MPFROMSHORT(CRA_CURSORED));
    1533             if(pci && (INT)pci != -1) {
    1534               if(fSplitStatus &&
    1535                  hwndStatus2) {
    1536                 commafmt(tb,sizeof(tb),pci->cbFile + pci->easize);
     1531            if(pci && (INT)pci != -1)
     1532            {
     1533              if(fSplitStatus && hwndStatus2)
     1534              {
     1535                CommaFmtULL(tb,sizeof(tb),pci->cbFile + pci->easize,' ');
    15371536                if(!fMoreButtons)
    15381537                  sprintf(s,
     
    15491548                else {
    15501549                  *tf = 0;
    1551                   if(pci->cbFile + pci->easize > 1024)
    1552                     commafmt(tf,sizeof(tf),
    1553                              (pci->cbFile + pci->easize) / 1024);
     1550                  if (pci->cbFile + pci->easize > 1024)
     1551                  {
     1552                    CommaFmtULL(tf,sizeof(tf),
     1553                                pci->cbFile + pci->easize,'K');
     1554                  }
    15541555                  sprintf(s,
    15551556                          GetPString(IDS_STATUSSIZETEXT),
    15561557                          tb,
    1557                           (*tf) ? " (" : NullStr,
     1558                          *tf ? " (" : NullStr,
    15581559                          tf,
    1559                           (*tf) ? "k)" : NullStr);
     1560                          *tf ? ")" : NullStr);
    15601561                }
    15611562                WinSetWindowText(hwndStatus2,s);
     
    34393440              PNOTIFYRECORDEMPHASIS pre = mp2;
    34403441              PCNRITEM              pci;
    3441               CHAR                  s[CCHMAXPATHCOMP + 91],tb[81],tf[81],
    3442                                     *tbk;
     3442              CHAR                  s[CCHMAXPATHCOMP + 91],tb[81],tf[81];
    34433443
    34443444              pci = (PCNRITEM)((pre) ? pre->pRecord : NULL);
     
    34673467                  dcd->selectedfiles--;
    34683468                }
    3469                 if(!dcd->suspendview) {
     3469                if(!dcd->suspendview)
     3470                {
    34703471                  commafmt(tf,sizeof(tf),dcd->selectedfiles);
    3471                   if(dcd->selectedbytes > 1024) {
    3472                     tbk = "k";
    3473                     commafmt(tb,sizeof(tb),dcd->selectedbytes / 1024L);
    3474                   }
    3475                   else {
    3476                     tbk = "b";
    3477                     commafmt(tb,sizeof(tb),dcd->selectedbytes);
    3478                   }
    3479                   sprintf(s,"%s / %s%s",tf,tb,tbk);
     3472                  CommaFmtULL(tb,sizeof(tb),dcd->selectedbytes,'K');
     3473                  sprintf(s,"%s / %s",tf,tb);
    34803474                  WinSetDlgItemText(dcd->hwndClient,DIR_SELECTED,s);
    34813475                }
     
    35003494                if(pre->fEmphasisMask & CRA_CURSORED) {
    35013495                  if(pci->rc.flRecordAttr & CRA_CURSORED) {
    3502                     if(fSplitStatus && hwndStatus2) {
    3503                       commafmt(tb,sizeof(tb),pci->cbFile + pci->easize);
     3496                    if(fSplitStatus && hwndStatus2)
     3497                    {
     3498                      CommaFmtULL(tb,sizeof(tb),pci->cbFile + pci->easize,' ');
    35043499                      if(!fMoreButtons)
     3500                      {
    35053501                        sprintf(s," %sb  %04u/%02u/%02u %02u:%02u:%02u  [%s]  %s",
    35063502                                tb,pci->date.year,
     
    35083504                                pci->time.minutes,pci->time.seconds,
    35093505                                pci->pszDispAttr,pci->pszFileName);
     3506                      }
    35103507                      else {
    35113508                        *tf = 0;
    35123509                        if(pci->cbFile + pci->easize > 1024)
    3513                           commafmt(tf,sizeof(tf),
    3514                                    (pci->cbFile + pci->easize) / 1024);
     3510                        {
     3511                          CommaFmtULL(tf,sizeof(tf),
     3512                                      pci->cbFile + pci->easize,'K');
     3513                        }
    35153514                        sprintf(s,GetPString(IDS_STATUSSIZETEXT),
    35163515                                tb,
    3517                                 (*tf) ? " (" : NullStr,
     3516                                *tf ? " (" : NullStr,
    35183517                                tf,
    3519                                 (*tf) ? "k)" : NullStr);
     3518                                *tf ? ")" : NullStr);
    35203519                      }
    35213520                      WinSetWindowText(hwndStatus2,s);
Note: See TracChangeset for help on using the changeset viewer.