Changeset 1105 for trunk/dll/dirsize.c
- Timestamp:
- Aug 3, 2008, 9:34:47 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/dirsize.c
r1104 r1105 37 37 version to NullStr and all others to NULL. 38 38 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory; use pTmpDir for temp files 39 03 Aug 08 GKY Reworked FillInRecSizes to use pci->pszDisplayName for display names and 40 created a more consitent string for passing to DRAWITEM. Finally (I hope) fixed 41 the strlen trap. 39 42 40 43 ***********************************************************************/ … … 176 179 pci->rc.hptrIcon = hptrDir; 177 180 pci->attrFile = 0; 178 pci->pszDispAttr = N ullStr;179 pci->pszSubject = N ullStr;181 pci->pszDispAttr = NULL; 182 pci->pszSubject = NULL; 180 183 } // if got something 181 184 else { … … 206 209 pci->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); 207 210 } 208 // fixme to understand this - appears to be indirectly saving length, but why?209 pci->pszDisplayName = pci->pszFileName + strlen(pci->pszFileName);211 // Use pszDisplayname for display so no need to save length of pszFileName 03 Aug 08 GKY 212 pci->pszDisplayName = pci->pszFileName; 210 213 pci->rc.pszIcon = pci->pszFileName; 211 214 pci->rc.flRecordAttr |= CRA_RECORDREADONLY; … … 305 308 306 309 float fltPct = 0.0; 307 USHORT c;308 310 CHAR szCurDir[80]; 309 311 CHAR szSubDir[80]; 310 312 CHAR szAllDir[80]; 311 CHAR szBar[ 80];312 CHAR szBuf[CCHMAXPATH + 3 20];313 CHAR szBar[101]; 314 CHAR szBuf[CCHMAXPATH + 341]; 313 315 314 316 // cbFile = currect directory usage in bytes 315 317 // easize = subdirectory usage in bytes 316 318 CommaFmtULL(szCurDir, sizeof(szCurDir), pci->cbFile, 'K'); 317 *szBar = 0;319 *szBar = NULL; 318 320 pci->pszLongName = NULL; 321 memset(szBuf, 0, sizeof(szBuf)); 319 322 if (ullTotalBytes) { 320 registerUINT cBar;323 UINT cBar; 321 324 322 325 if (isroot) { … … 338 341 fltPct = (((float)pci->cbFile + pci->easize) * 100.0) / ullTotalBytes; 339 342 343 //Second line for graph reworked 03 AUG 08 GKY 344 memset(szBar, ' ', sizeof(szBar)); 340 345 cBar = (UINT) fltPct / 2; 341 if (cBar) 342 memset(szBar, '#', cBar); 343 if (cBar * 2 != (UINT) fltPct) { 344 szBar[cBar] = '='; 345 cBar++; 346 } 347 if (cBar < 50) 348 memset(szBar + cBar, ' ', 50 - cBar); 349 szBar[50] = 0; 346 if (cBar && cBar * 2 != (UINT) fltPct) 347 szBar[cBar] = '='; 348 szBar[100] = 0; 350 349 } 351 350 … … 353 352 CommaFmtULL(szSubDir, sizeof(szSubDir), pci->easize, 'K'); 354 353 CommaFmtULL(szAllDir, sizeof(szAllDir), pci->cbFile + pci->easize, 'K'); 355 c = pci->pszDisplayName - pci->pszFileName;356 354 sprintf(szBuf, 357 355 "%s %s + %s = %s (%.02lf%%%s)\r%s", … … 363 361 isroot ? GetPString(IDS_OFDRIVETEXT) : NullStr, 364 362 szBar); 365 free(pci->pszFileName); 366 pci->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); 367 pci->pszDisplayName = pci->pszFileName + c; 368 WinSendMsg(hwndCnr, 369 CM_INVALIDATERECORD, MPFROMP(&pci), MPFROM2SHORT(1, 0)); 363 pci->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__); 364 // use DisplayName for display hopefully fixes "strlen" trap 02 AUG 08 GKY 365 if (pci->pszDisplayName) 366 WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPFROMP(&pci), MPFROM2SHORT(1, 0)); 370 367 isroot = FALSE; 371 368 } … … 396 393 } 397 394 if (pciParent) { 398 p = strchr(pciParent->psz FileName, '\r');395 p = strchr(pciParent->pszDisplayName, '\r'); // GKY use display name for display 399 396 if (p) 400 397 *p = 0; 401 398 fprintf(fp, "%*.*s%s %lu %s%s\n", 402 399 indent * 2, indent * 2, " ", 403 pciParent->psz FileName,400 pciParent->pszDisplayName, // 404 401 pciParent->attrFile, 405 402 GetPString(IDS_FILETEXT), &"s"[pciParent->attrFile == 1]); … … 434 431 # ifdef FORTIFY 435 432 Fortify_EnterScope(); 433 Fortify_BecomeOwner(dirsize); // We free dirsize 436 434 # endif 437 435 … … 664 662 LONG yBottom; 665 663 INT boxHeight; 666 p = strchr(pci->psz FileName, '\r');664 p = strchr(pci->pszDisplayName, '\r'); 667 665 if (p) { 668 666 // draw text … … 681 679 682 680 // Calculate nominal graph box height based on font size 683 GpiQueryTextBox(oi->hps, p - pci->psz FileName,684 pci->psz FileName, TXTBOX_COUNT, aptl);681 GpiQueryTextBox(oi->hps, p - pci->pszDisplayName, 682 pci->pszDisplayName, TXTBOX_COUNT, aptl); 685 683 boxHeight = aptl[TXTBOX_TOPRIGHT].y - aptl[TXTBOX_BOTTOMRIGHT].y; 686 684 boxHeight -= 4; … … 694 692 ptl.y = yBottom + boxHeight + 6; // 03 Aug 07 SHL 695 693 // GpiMove(oi->hps, &ptl); 696 GpiCharStringAt(oi->hps, &ptl, p - pci->psz FileName,697 pci->psz FileName);694 GpiCharStringAt(oi->hps, &ptl, p - pci->pszDisplayName, 695 pci->pszDisplayName); 698 696 699 697 *p = '\r'; // Restore … … 852 850 while (pci && (INT) pci != -1) { 853 851 memset(szTemp, 0, sizeof(szTemp)); 854 strncpy(szTemp, pci->pszFileName, 855 pci->pszDisplayName - pci->pszFileName); 852 strcpy(szTemp, pci->pszFileName); 856 853 strrev(szTemp); 857 854 if (*szFileName && *szTemp != '\\')
Note:
See TracChangeset
for help on using the changeset viewer.