Changeset 730 for trunk/dll/dirsize.c


Ignore:
Timestamp:
Jul 22, 2007, 7:57:09 PM (18 years ago)
Author:
Gregg Young
Message:

Preliminary work on variable sized container buffers. Removes szFileName etc. Builds fine but traps.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/dirsize.c

    r689 r730  
    9797  RECORDINSERT ri;
    9898  PCNRITEM pCI;
     99  CHAR *f = 0;
    99100
    100101  // fixme to report errors
     
    146147    else
    147148      DosError(FERR_DISABLEHARDERR);
    148     pCI->pszLongname = pCI->szFileName;
     149    pCI->pszLongname = pCI->pszFileName;
    149150    pCI->rc.hptrIcon = hptrDir;
    150     *pCI->szDispAttr = *pCI->szLongname = *pCI->szSubject = 0;
    151     pCI->attrFile = 0L;
     151    *pCI->szDispAttr = 0;
     152    pCI->attrFile = 0;
     153    pCI->pszLongname = xstrdup(f, pszSrcFile, __LINE__);
     154    pCI->pszSubject = xstrdup(f, pszSrcFile, __LINE__);
    152155  }
    153156  else {
     
    162165
    163166  if (strlen(pszFileName) < 4 || top)
    164     strcpy(pCI->szFileName, pszFileName);
     167   pCI->pszFileName = xstrdup(pszFileName, pszSrcFile, __LINE__);
    165168  else {
    166169    p = strrchr(pszFileName, '\\');
     
    170173      p++;
    171174    sp = (strchr(pszFileName, ' ') != NULL) ? "\"" : NullStr;
    172     pp = pCI->szFileName;
     175    pp = pCI->pszFileName;
    173176    if (*sp) {
    174177      *pp = *sp;
     
    180183      strcat(pp, sp);
    181184  }
    182   pCI->pszFileName = pCI->szFileName + strlen(pCI->szFileName);
     185  pCI->pszFileName = pCI->pszFileName + strlen(pCI->pszFileName);
    183186  pCI->rc.pszIcon = pCI->pszLongname;
    184187  pCI->rc.flRecordAttr |= CRA_RECORDREADONLY;
    185188  if (fForceUpper)
    186     strupr(pCI->szFileName);
     189    strupr(pCI->pszFileName);
    187190  else if (fForceLower)
    188     strlwr(pCI->szFileName);
     191    strlwr(pCI->pszFileName);
    189192  memset(&ri, 0, sizeof(RECORDINSERT));
    190193  ri.cb = sizeof(RECORDINSERT);
     
    293296
    294297        memset(&fsa, 0, sizeof(fsa));
    295         rc = DosQueryFSInfo(toupper(*pCI->szFileName) - '@', FSIL_ALLOC, &fsa,
     298        rc = DosQueryFSInfo(toupper(*pCI->pszFileName) - '@', FSIL_ALLOC, &fsa,
    296299                            sizeof(FSALLOCATE));
    297300        if (!rc) {
     
    299302            ((float)fsa.cUnit * (fsa.cSectorUnit * fsa.cbSector));
    300303        }
    301         pCI->szLongname[1] = 1;         // Flag root - hack cough
     304        pCI->pszLongname[1] = 1;                // Flag root - hack cough
    302305      }
    303306      else
     
    319322    CommaFmtULL(szSubDir, sizeof(szSubDir), pCI->easize, 'K');
    320323    CommaFmtULL(szAllDir, sizeof(szAllDir), pCI->cbFile + pCI->easize, 'K');
    321     sprintf(&pCI->szFileName[strlen(pCI->szFileName)],
     324    sprintf(&pCI->pszFileName[strlen(pCI->pszFileName)],
    322325            "  %s + %s = %s (%.02lf%%%s)\r%s",
    323326            szCurDir,
     
    355358  }
    356359  if (pciParent) {
    357     p = strchr(pciParent->szFileName, '\r');
     360    p = strchr(pciParent->pszFileName, '\r');
    358361    if (p)
    359362      *p = 0;
    360363    fprintf(fp, "%*.*s%s %lu %s%s\n",
    361364            indent * 2, indent * 2, " ",
    362             pciParent->szFileName,
     365            pciParent->pszFileName,
    363366            pciParent->attrFile,
    364367            GetPString(IDS_FILETEXT), &"s"[pciParent->attrFile == 1]);
     
    588591            LONG clr, x;
    589592
    590             p = strchr(pci->szFileName, '\r');
     593            p = strchr(pci->pszFileName, '\r');
    591594            if (p) {
    592595              /* draw text */
     
    600603              GpiSetMix(oi->hps, FM_OVERPAINT);
    601604              *p = 0;
    602               GpiQueryTextBox(oi->hps, strlen(pci->szFileName),
    603                               pci->szFileName, TXTBOX_COUNT, aptl);
     605              GpiQueryTextBox(oi->hps, strlen(pci->pszFileName),
     606                              pci->pszFileName, TXTBOX_COUNT, aptl);
    604607              ptl.x = oi->rclItem.xLeft;
    605608              ptl.y = (oi->rclItem.yTop - aptl[TXTBOX_TOPRIGHT].y);
    606609              GpiMove(oi->hps, &ptl);
    607               GpiCharString(oi->hps, strlen(pci->szFileName),
    608                             pci->szFileName);
     610              GpiCharString(oi->hps, strlen(pci->pszFileName),
     611                            pci->pszFileName);
    609612              *p = '\r';
    610613
     
    663666              /* fill box with graph bar, flags is integer % */
    664667              if (pci->flags) {
    665                 if (pci->szLongname[1] == 1)    /* is root record */
     668                if (*(pci->pszLongname + 1) == 1)       /* is root record */
    666669                  GpiSetColor(oi->hps, CLR_DARKGREEN);
    667670                else
     
    675678
    676679                /* draw highlights and shadows on graph */
    677                 if (pci->szLongname[1] == 1)
     680                if (*(pci->pszLongname + 1) == 1)
    678681                  GpiSetColor(oi->hps, CLR_GREEN);
    679682                else
     
    692695                ptl.x = oi->rclItem.xLeft + pci->flags;
    693696                GpiLine(oi->hps, &ptl);
    694                 if (pci->szLongname[1] != 1) {
     697                if (*(pci->pszLongname + 1) != 1) {
    695698                  GpiSetColor(oi->hps, CLR_DARKRED);
    696699                  ptl.x = oi->rclItem.xLeft + 2;
     
    752755          while (pci && (INT) pci != -1) {
    753756            memset(szTemp, 0, sizeof(szTemp));
    754             strncpy(szTemp, pci->szFileName,
    755                     pci->pszFileName - pci->szFileName);
     757            strncpy(szTemp, pci->pszFileName,
     758                    pci->pszFileName - pci->pszFileName);
    756759            strrev(szTemp);
    757760            if (*pszFileName && *szTemp != '\\')
Note: See TracChangeset for help on using the changeset viewer.