Changeset 781 for trunk/dll/dirsize.c
- Timestamp:
- Aug 12, 2007, 5:04:05 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/dirsize.c
r780 r781 28 28 03 Aug 07 SHL DirSizeProc; correct sizing and positioning to be deterministic 29 29 06 Aug 07 GKY Reduce DosSleep times (ticket 148) 30 30 11 Aug 07 SHL ProcessDir: remove unneeded reallocs 31 31 32 32 ***********************************************************************/ … … 36 36 #define INCL_GPI 37 37 #define INCL_LONGLONG 38 #define INCL_DOSERRORS 38 39 #include <os2.h> 39 40 … … 99 100 ULONGLONG ull; 100 101 HDIR hdir; 101 FILEFINDBUF4 *pffb , *pffbTemp;102 FILEFINDBUF4 *pffb; 102 103 APIRET rc; 103 104 RECORDINSERT ri; … … 107 108 *pullTotalBytes = 0; // In case we fail 108 109 109 pffb = xmalloc(sizeof(FILEFINDBUF4) , pszSrcFile, __LINE__);110 pffb = xmalloc(sizeof(FILEFINDBUF4) * FilesToGet, pszSrcFile, __LINE__); 110 111 if (!pffb) 111 return FALSE; 112 return FALSE; // Error already reported 113 112 114 strcpy(maskstr, pszFileName); 113 115 if (maskstr[strlen(maskstr) - 1] != '\\') … … 115 117 pEndMask = &maskstr[strlen(maskstr)]; // Point after last backslash 116 118 strcat(maskstr, "*"); 117 //printf("%s\n",maskstr);118 119 119 120 hdir = HDIR_CREATE; 120 121 nm = 1; 122 // 11 Aug 07 SHL fixme to know if we can bypass memset 121 123 memset(pffb, 0, sizeof(FILEFINDBUF4)); 122 124 DosError(FERR_DISABLEHARDERR); 123 // printf("FIND1\n");125 // Check directory exists 124 126 rc = DosFindFirst(pszFileName, &hdir, 125 127 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | … … 156 158 pci->pszDispAttr = NullStr; 157 159 pci->pszSubject = NullStr; 158 } 160 } // if got something 159 161 else { 162 // No match 160 163 free(pffb); 161 Dos_Error(MB_ENTER, 162 rc, 163 HWND_DESKTOP, 164 pszSrcFile, 165 __LINE__, GetPString(IDS_CANTFINDDIRTEXT), pszFileName); 164 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 165 GetPString(IDS_CANTFINDDIRTEXT), pszFileName); 166 166 return FALSE; 167 167 } … … 188 188 // fixme to know why - it appears to be indirectly saving length, but why? 189 189 pci->pszDisplayName = pci->pszFileName + strlen(pci->pszFileName); 190 pci->pszLongName = pci->pszFileName; 190 pci->pszLongName = pci->pszFileName; // fixme to be sure? 191 191 pci->rc.pszIcon = pci->pszFileName; 192 192 pci->rc.flRecordAttr |= CRA_RECORDREADONLY; … … 207 207 return FALSE; 208 208 } 209 210 // Find files and directories in this directory 209 211 hdir = HDIR_CREATE; 210 pffbTemp = pffb;211 212 nm = FilesToGet; 212 pffb = xrealloc(pffb, (nm + 1) * sizeof(FILEFINDBUF4), pszSrcFile, __LINE__);213 if (!pffb) { //Error already sent214 free(pffbTemp);215 return FALSE;216 }217 213 rc = DosFindFirst(maskstr, &hdir, 218 214 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | 219 215 FILE_SYSTEM | FILE_HIDDEN | FILE_DIRECTORY, 220 pffb, (nm + 1)* sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE);216 pffb, nm * sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE); 221 217 if (!rc) { 222 register PBYTE fb = (PBYTE)pffb;218 PBYTE fb = (PBYTE)pffb; 223 219 FILEFINDBUF4 *pffbFile; 224 220 ULONG x; 225 UINT y = 1;226 221 227 222 while (!rc) { 228 223 priority_normal(); 229 //printf("Found %lu\n",nm);230 224 for (x = 0; x < nm; x++) { 231 pffbFile = (FILEFINDBUF4 *) fb; 232 //printf("%s\n",pffbFile->achName); 233 //fflush(stdout); 225 pffbFile = (FILEFINDBUF4 *)fb; 234 226 // Total size skipping . and .. 235 227 if ((~pffbFile->attrFile & FILE_DIRECTORY) || … … 256 248 break; 257 249 fb += pffbFile->oNextEntryOffset; 258 } 250 } // for matches 259 251 if (*pchStopFlag) 260 252 break; 261 253 DosSleep(1); 262 pffbTemp = pffb; 263 nm = FilesToGet; /* FilesToGet */ 264 y++; 265 pffb = xrealloc(pffb, y * (nm + 1) * sizeof(FILEFINDBUF4), pszSrcFile, __LINE__); 266 if (!pffb) { //Error already sent 267 free(pffbTemp); 268 break; 269 } 254 nm = FilesToGet; 270 255 DosError(FERR_DISABLEHARDERR); 271 rc = DosFindNext(hdir, pffb, y * (nm + 1) * sizeof(FILEFINDBUF4), &nm); 272 } // while more found 256 rc = DosFindNext(hdir, pffb, sizeof(FILEFINDBUF4) * FilesToGet, &nm); 257 } // while more found 258 259 if (rc != ERROR_NO_MORE_FILES) { 260 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 261 GetPString(IDS_CANTFINDDIRTEXT), pszFileName); 262 } 263 273 264 DosFindClose(hdir); 274 265 priority_normal(); 275 } 266 } // if got files or directories 276 267 277 268 free(pffb); … … 323 314 // Need unique buffer 23 Jul 07 SHL 324 315 pci->pszLongName = xmalloc(2, pszSrcFile, __LINE__); 325 pci->pszLongName[0] = 0; 326 pci->pszLongName[1] = 1; 316 pci->pszLongName[0] = 0; // Make null string 317 pci->pszLongName[1] = 1; // Flag root - hack cough 327 318 } 328 319 else … … 632 623 p = strchr(pci->pszFileName, '\r'); 633 624 if (p) { 634 / * draw text */635 if (!pci->cbFile) / * no size */625 // draw text 626 if (!pci->cbFile) // no size 636 627 GpiSetColor(oi->hps, CLR_DARKGRAY); 637 else if (!pci->easize) / * no size below */628 else if (!pci->easize) // no size below 638 629 GpiSetColor(oi->hps, CLR_DARKBLUE); 639 630 else … … 656 647 // Place text above graph box with a bit of whitespace between 657 648 ptl.x = oi->rclItem.xLeft; 658 ptl.y = yBottom + boxHeight + 8; 649 ptl.y = yBottom + boxHeight + 8; // 03 Aug 07 SHL 659 650 // GpiMove(oi->hps, &ptl); 660 651 GpiCharStringAt(oi->hps, &ptl, strlen(pci->pszFileName), … … 663 654 *p = '\r'; // Restore 664 655 665 / * draw the graph box */656 // draw the graph box 666 657 // GpiQueryTextBox(oi->hps, 1, "#", TXTBOX_COUNT, aptl); // 03 Aug 07 SHL 667 / * draw black outline */658 // draw black outline 668 659 GpiSetColor(oi->hps, CLR_BLACK); 669 660 ptl.x = oi->rclItem.xLeft; … … 673 664 ptl.y = yBottom + boxHeight; 674 665 GpiBox(oi->hps, DRO_OUTLINE, &ptl, 0, 0); 675 / * fill with gray */666 // fill with gray 676 667 GpiSetColor(oi->hps, CLR_PALEGRAY); 677 668 ptl.x = oi->rclItem.xLeft + 1; … … 682 673 GpiBox(oi->hps, DRO_OUTLINEFILL, &ptl, 0, 0); 683 674 684 / * draw shadow at bottom & right sides */675 // draw shadow at bottom & right sides 685 676 GpiSetColor(oi->hps, CLR_DARKGRAY); 686 677 ptl.x = oi->rclItem.xLeft + 1; … … 692 683 GpiLine(oi->hps, &ptl); 693 684 694 / * draw highlight at top and left sides */685 // draw highlight at top and left sides 695 686 GpiSetColor(oi->hps, CLR_WHITE); 696 687 ptl.x = oi->rclItem.xLeft + 1; … … 699 690 GpiLine(oi->hps, &ptl); 700 691 701 / * draw shadow of box */692 // draw shadow of box 702 693 GpiSetColor(oi->hps, CLR_DARKGRAY); 703 694 ptl.x = oi->rclItem.xLeft + 2; … … 715 706 GpiLine(oi->hps, &ptl); 716 707 717 / * fill box with graph bar, flags is integer % */708 // fill box with graph bar, flags is integer % 718 709 if (pci->flags) { 719 if (*(pci->pszLongName + 1) == 1) / * is root record */710 if (*(pci->pszLongName + 1) == 1) // is root record 720 711 GpiSetColor(oi->hps, CLR_DARKGREEN); 721 712 else … … 728 719 GpiBox(oi->hps, DRO_OUTLINEFILL, &ptl, 0, 0); 729 720 730 / * draw highlights and shadows on graph */721 // draw highlights and shadows on graph 731 722 if (*(pci->pszLongName + 1) == 1) 732 723 GpiSetColor(oi->hps, CLR_GREEN); … … 756 747 } 757 748 758 / * draw hash marks in box */749 // draw hash marks in box 759 750 GpiSetColor(oi->hps, CLR_WHITE); 760 751 clr = CLR_WHITE;
Note:
See TracChangeset
for help on using the changeset viewer.