Changeset 738 for trunk/dll/dirsize.c
- Timestamp:
- Jul 24, 2007, 5:22:59 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/dirsize.c
r731 r738 24 24 18 Feb 07 GKY Add new drive type icons 25 25 22 Mar 07 GKY Use QWL_USER 26 23 Jul 07 SHL Sync with naming standards 26 27 27 28 ***********************************************************************/ … … 49 50 CHAR *pchStopFlag; 50 51 DIRCNRDATA *pDCD; 51 } 52 DIRSIZE; 52 } DIRSIZE; 53 53 54 54 typedef struct … … 59 59 BOOL working; 60 60 HPOINTER hptr; 61 } 62 tState; 61 } tState; 63 62 64 63 static PSZ pszSrcFile = __FILE__; … … 95 94 ULONGLONG ull; 96 95 HDIR hdir; 97 FILEFINDBUF4 *p FFB;96 FILEFINDBUF4 *pffb; 98 97 APIRET rc; 99 98 RECORDINSERT ri; 100 PCNRITEM p CI;99 PCNRITEM pci; 101 100 102 101 // fixme to report errors 103 102 *pullTotalBytes = 0; // In case we fail 104 103 105 p FFB= xmalloc(sizeof(FILEFINDBUF4), pszSrcFile, __LINE__);106 if (!p FFB)104 pffb = xmalloc(sizeof(FILEFINDBUF4), pszSrcFile, __LINE__); 105 if (!pffb) 107 106 return FALSE; 108 107 strcpy(maskstr, pszFileName); … … 115 114 hdir = HDIR_CREATE; 116 115 nm = 1L; 117 memset(p FFB, 0, sizeof(FILEFINDBUF4));116 memset(pffb, 0, sizeof(FILEFINDBUF4)); 118 117 DosError(FERR_DISABLEHARDERR); 119 118 //printf("FIND1\n"); … … 121 120 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | 122 121 FILE_SYSTEM | FILE_HIDDEN | MUST_HAVE_DIRECTORY, 123 p FFB, sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE);122 pffb, sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE); 124 123 125 124 if (!rc) … … 131 130 * requesting EASIZE. sheesh. 132 131 */ 133 if ((!rc && (p FFB->attrFile & FILE_DIRECTORY)) || strlen(pszFileName) < 4) {132 if ((!rc && (pffb->attrFile & FILE_DIRECTORY)) || strlen(pszFileName) < 4) { 134 133 if (*pchStopFlag) { 135 free(p FFB);134 free(pffb); 136 135 return FALSE; 137 136 } 138 p CI= WinSendMsg(hwndCnr, CM_ALLOCRECORD, MPFROMLONG(EXTRA_RECORD_BYTES2),137 pci = WinSendMsg(hwndCnr, CM_ALLOCRECORD, MPFROMLONG(EXTRA_RECORD_BYTES2), 139 138 MPFROMLONG(1L)); 140 if (!p CI) {141 free(p FFB);139 if (!pci) { 140 free(pffb); 142 141 return FALSE; 143 142 } 144 143 if (!rc) { 145 ullCurDirBytes = p FFB->cbFile;146 ullCurDirBytes += CBLIST_TO_EASIZE(p FFB->cbList);144 ullCurDirBytes = pffb->cbFile; 145 ullCurDirBytes += CBLIST_TO_EASIZE(pffb->cbList); 147 146 } 148 147 else 149 148 DosError(FERR_DISABLEHARDERR); 150 149 // fixme to not double free when pointers match 151 p CI->pszLongname = pCI->pszFileName;152 p CI->rc.hptrIcon = hptrDir;153 *p CI->szDispAttr = 0;154 p CI->attrFile = 0;155 p CI->pszSubject = xstrdup(NullStr, pszSrcFile, __LINE__);150 pci->pszLongname = pci->pszFileName; 151 pci->rc.hptrIcon = hptrDir; 152 *pci->szDispAttr = 0; 153 pci->attrFile = 0; 154 pci->pszSubject = xstrdup(NullStr, pszSrcFile, __LINE__); 156 155 } 157 156 else { 158 free(p FFB);157 free(pffb); 159 158 Dos_Error(MB_ENTER, 160 159 rc, … … 166 165 167 166 if (strlen(pszFileName) < 4 || top) 168 p CI->pszFileName = xstrdup(pszFileName, pszSrcFile, __LINE__);167 pci->pszFileName = xstrdup(pszFileName, pszSrcFile, __LINE__); 169 168 else { 170 169 p = strrchr(pszFileName, '\\'); … … 174 173 p++; 175 174 sp = (strchr(pszFileName, ' ') != NULL) ? "\"" : NullStr; 176 pp = p CI->pszFileName;175 pp = pci->pszFileName; 177 176 if (*sp) { 178 177 *pp = *sp; … … 184 183 strcat(pp, sp); 185 184 } 186 p CI->rc.pszIcon = pCI->pszLongname;187 p CI->rc.flRecordAttr |= CRA_RECORDREADONLY;185 pci->rc.pszIcon = pci->pszLongname; 186 pci->rc.flRecordAttr |= CRA_RECORDREADONLY; 188 187 if (fForceUpper) 189 strupr(p CI->pszFileName);188 strupr(pci->pszFileName); 190 189 else if (fForceLower) 191 strlwr(p CI->pszFileName);190 strlwr(pci->pszFileName); 192 191 // fixme to work - code is hiding file name from container but... 23 Jul 07 SHL 193 p CI->pszFileName = pCI->pszFileName + strlen(pCI->pszFileName);192 pci->pszFileName = pci->pszFileName + strlen(pci->pszFileName); 194 193 memset(&ri, 0, sizeof(RECORDINSERT)); 195 194 ri.cb = sizeof(RECORDINSERT); … … 199 198 ri.cRecordsInsert = 1L; 200 199 ri.fInvalidateRecord = TRUE; 201 if (!WinSendMsg(hwndCnr, CM_INSERTRECORD, MPFROMP(p CI), MPFROMP(&ri))) {202 free(p FFB);200 if (!WinSendMsg(hwndCnr, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) { 201 free(pffb); 203 202 return FALSE; 204 203 } … … 208 207 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | 209 208 FILE_SYSTEM | FILE_HIDDEN | FILE_DIRECTORY, 210 p FFB, sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE);209 pffb, sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE); 211 210 if (!rc) { 212 register PBYTE fb = (PBYTE) p FFB;211 register PBYTE fb = (PBYTE) pffb; 213 212 FILEFINDBUF4 *pffbFile; 214 213 ULONG x; … … 230 229 231 230 if (!(pffbFile->attrFile & FILE_DIRECTORY)) 232 p CI->attrFile++; // Bump file count231 pci->attrFile++; // Bump file count 233 232 if (*pchStopFlag) 234 233 break; … … 237 236 strcpy(pEndMask, pffbFile->achName); // Append dirname to base dirname 238 237 if (!*pchStopFlag) { 239 ProcessDir(hwndCnr, maskstr, p CI, pchStopFlag, FALSE, &ull);238 ProcessDir(hwndCnr, maskstr, pci, pchStopFlag, FALSE, &ull); 240 239 ullSubDirBytes += ull; 241 240 } … … 250 249 DosSleep(0L); 251 250 nm = 1L; /* FilesToGet */ 252 rc = DosFindNext(hdir, p FFB, sizeof(FILEFINDBUF4), &nm);251 rc = DosFindNext(hdir, pffb, sizeof(FILEFINDBUF4), &nm); 253 252 } // while more found 254 253 DosFindClose(hdir); … … 256 255 } 257 256 258 free(p FFB);259 260 p CI->cbFile = ullCurDirBytes;261 p CI->easize = ullSubDirBytes; // hack cough262 WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPFROMP(&p CI),257 free(pffb); 258 259 pci->cbFile = ullCurDirBytes; 260 pci->easize = ullSubDirBytes; // hack cough 261 WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPFROMP(&pci), 263 262 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED)); 264 263 … … 271 270 BOOL isroot) 272 271 { 273 PCNRITEM p CI= pciParent;272 PCNRITEM pci = pciParent; 274 273 SHORT attrib = CMA_FIRSTCHILD; 275 274 276 if (p CI) {275 if (pci) { 277 276 278 277 float fltPct = 0.0; … … 284 283 // cbFile = currect directory usage in bytes 285 284 // easize = subdirectory usage in bytes 286 CommaFmtULL(szCurDir, sizeof(szCurDir), p CI->cbFile, 'K');285 CommaFmtULL(szCurDir, sizeof(szCurDir), pci->cbFile, 'K'); 287 286 *szBar = 0; 288 287 … … 295 294 296 295 memset(&fsa, 0, sizeof(fsa)); 297 rc = DosQueryFSInfo(toupper(*p CI->pszFileName) - '@', FSIL_ALLOC, &fsa,296 rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@', FSIL_ALLOC, &fsa, 298 297 sizeof(FSALLOCATE)); 299 298 if (!rc) { … … 302 301 } 303 302 // Need unique buffer 23 Jul 07 SHL 304 p CI->pszLongname = xmalloc(2, pszSrcFile, __LINE__);305 p CI->pszLongname[0] = 0; // Make null string306 p CI->pszLongname[1] = 1; // Flag root - hack cough303 pci->pszLongname = xmalloc(2, pszSrcFile, __LINE__); 304 pci->pszLongname[0] = 0; // Make null string 305 pci->pszLongname[1] = 1; // Flag root - hack cough 307 306 } 308 307 else 309 fltPct = (((float)p CI->cbFile + pCI->easize) * 100.0) / ullTotalBytes;308 fltPct = (((float)pci->cbFile + pci->easize) * 100.0) / ullTotalBytes; 310 309 311 310 cBar = (UINT) fltPct / 2; … … 321 320 } 322 321 323 p CI->flags = (ULONG) fltPct;324 CommaFmtULL(szSubDir, sizeof(szSubDir), p CI->easize, 'K');325 CommaFmtULL(szAllDir, sizeof(szAllDir), p CI->cbFile + pCI->easize, 'K');326 p CI->pszFileName = xrealloc(pCI->pszFileName, strlen(pCI->pszFileName) + 100,322 pci->flags = (ULONG) fltPct; 323 CommaFmtULL(szSubDir, sizeof(szSubDir), pci->easize, 'K'); 324 CommaFmtULL(szAllDir, sizeof(szAllDir), pci->cbFile + pci->easize, 'K'); 325 pci->pszFileName = xrealloc(pci->pszFileName, strlen(pci->pszFileName) + 100, 327 326 pszSrcFile, 328 327 __LINE__); // 23 Jul 07 SHL 329 sprintf(p CI->pszFileName + strlen(pCI->pszFileName),328 sprintf(pci->pszFileName + strlen(pci->pszFileName), 330 329 " %s + %s = %s (%.02lf%%%s)\r%s", 331 330 szCurDir, … … 334 333 fltPct, isroot ? GetPString(IDS_OFDRIVETEXT) : NullStr, szBar); 335 334 WinSendMsg(hwndCnr, 336 CM_INVALIDATERECORD, MPFROMP(&p CI), MPFROM2SHORT(1, 0));335 CM_INVALIDATERECORD, MPFROMP(&pci), MPFROM2SHORT(1, 0)); 337 336 isroot = FALSE; 338 337 } 339 338 else 340 339 attrib = CMA_FIRST; 341 p CI = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pCI),340 pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci), 342 341 MPFROM2SHORT(attrib, CMA_ITEMORDER)); 343 while (p CI && (INT) pCI!= -1) {342 while (pci && (INT) pci != -1) { 344 343 if (*pchStopFlag) 345 344 break; 346 FillInRecSizes(hwndCnr, p CI, ullTotalBytes, pchStopFlag, isroot);345 FillInRecSizes(hwndCnr, pci, ullTotalBytes, pchStopFlag, isroot); 347 346 isroot = FALSE; 348 p CI = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pCI),347 pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci), 349 348 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 350 349 } … … 355 354 { 356 355 PCNRITEM pci; 357 registerCHAR *p;356 CHAR *p; 358 357 359 358 if (!pciParent) {
Note:
See TracChangeset
for help on using the changeset viewer.