Changeset 551 for trunk/dll/dirsize.c
- Timestamp:
- Feb 28, 2007, 2:33:51 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/dirsize.c
r517 r551 40 40 #include "fm3str.h" 41 41 42 typedef struct { 43 CHAR *pszFileName; 44 HWND hwndCnr; 45 CHAR *pchStopFlag; 46 DIRCNRDATA *pDCD; 47 } DIRSIZE; 48 49 typedef struct { 50 CHAR szDirName[CCHMAXPATH]; 51 CHAR chStopFlag; 52 BOOL dying; 53 BOOL working; 54 HPOINTER hptr; 55 } tState; 56 42 typedef struct 43 { 44 CHAR *pszFileName; 45 HWND hwndCnr; 46 CHAR *pchStopFlag; 47 DIRCNRDATA *pDCD; 48 } 49 DIRSIZE; 50 51 typedef struct 52 { 53 CHAR szDirName[CCHMAXPATH]; 54 CHAR chStopFlag; 55 BOOL dying; 56 BOOL working; 57 HPOINTER hptr; 58 } 59 tState; 57 60 58 61 static PSZ pszSrcFile = __FILE__; … … 61 64 #pragma alloc_text(DIRSIZE2,PrintToFile,FillInRecSizes,SortSizeCnr) 62 65 63 static SHORT APIENTRY SortSizeCnr (PMINIRECORDCORE p1,PMINIRECORDCORE p2,64 66 static SHORT APIENTRY SortSizeCnr(PMINIRECORDCORE p1, PMINIRECORDCORE p2, 67 PVOID SortFlags) 65 68 { 66 69 ULONGLONG size1; 67 70 ULONGLONG size2; 68 71 69 size1 = ((PCNRITEM) p1)->cbFile + ((PCNRITEM)p1)->easize;70 size2 = ((PCNRITEM) p2)->cbFile + ((PCNRITEM)p2)->easize;72 size1 = ((PCNRITEM) p1)->cbFile + ((PCNRITEM) p1)->easize; 73 size2 = ((PCNRITEM) p2)->cbFile + ((PCNRITEM) p2)->easize; 71 74 return (size1 < size2) ? 1 : (size1 == size2) ? 0 : -1; 72 75 } 73 76 74 75 static BOOL ProcessDir(HWND hwndCnr,CHAR *pszFileName, 76 PCNRITEM pciParent, 77 CHAR *pchStopFlag,BOOL top, 77 static BOOL ProcessDir(HWND hwndCnr, CHAR * pszFileName, 78 PCNRITEM pciParent, 79 CHAR * pchStopFlag, BOOL top, 78 80 PULONGLONG pullTotalBytes) 79 81 { 80 CHAR 81 CHAR 82 register char 83 register char 84 register char 85 ULONG 86 ULONGLONG 87 ULONGLONG 88 ULONGLONG 89 HDIR 90 FILEFINDBUF4 91 APIRET 92 RECORDINSERT 93 PCNRITEM 82 CHAR maskstr[CCHMAXPATH]; 83 CHAR *pEndMask; 84 register char *p; 85 register char *sp; 86 register char *pp; 87 ULONG nm; 88 ULONGLONG ullCurDirBytes = 0; 89 ULONGLONG ullSubDirBytes = 0; 90 ULONGLONG ull; 91 HDIR hdir; 92 FILEFINDBUF4 *pFFB; 93 APIRET rc; 94 RECORDINSERT ri; 95 PCNRITEM pCI; 94 96 95 97 // fixme to report errors 96 *pullTotalBytes = 0; // In case we fail97 98 pFFB = xmalloc(sizeof(FILEFINDBUF4), pszSrcFile,__LINE__);99 if (!pFFB)98 *pullTotalBytes = 0; // In case we fail 99 100 pFFB = xmalloc(sizeof(FILEFINDBUF4), pszSrcFile, __LINE__); 101 if (!pFFB) 100 102 return FALSE; 101 strcpy(maskstr, pszFileName);102 if (maskstr[strlen(maskstr) - 1] != '\\')103 strcat(maskstr, "\\");103 strcpy(maskstr, pszFileName); 104 if (maskstr[strlen(maskstr) - 1] != '\\') 105 strcat(maskstr, "\\"); 104 106 pEndMask = &maskstr[strlen(maskstr)]; // Point after last backslash 105 strcat(maskstr, "*");107 strcat(maskstr, "*"); 106 108 //printf("%s\n",maskstr); 107 109 108 110 hdir = HDIR_CREATE; 109 111 nm = 1L; 110 memset(pFFB, 0,sizeof(FILEFINDBUF4));112 memset(pFFB, 0, sizeof(FILEFINDBUF4)); 111 113 DosError(FERR_DISABLEHARDERR); 112 114 //printf("FIND1\n"); … … 114 116 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | 115 117 FILE_SYSTEM | FILE_HIDDEN | MUST_HAVE_DIRECTORY, 116 pFFB, sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE);117 118 if (!rc)118 pFFB, sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE); 119 120 if (!rc) 119 121 DosFindClose(hdir); 120 122 … … 124 126 * requesting EASIZE. sheesh. 125 127 */ 126 if ((!rc && (pFFB->attrFile & FILE_DIRECTORY)) || 127 strlen(pszFileName) < 4) 128 { 128 if ((!rc && (pFFB->attrFile & FILE_DIRECTORY)) || strlen(pszFileName) < 4) { 129 129 if (*pchStopFlag) { 130 130 free(pFFB); 131 131 return FALSE; 132 132 } 133 pCI = WinSendMsg(hwndCnr, CM_ALLOCRECORD,MPFROMLONG(EXTRA_RECORD_BYTES2),133 pCI = WinSendMsg(hwndCnr, CM_ALLOCRECORD, MPFROMLONG(EXTRA_RECORD_BYTES2), 134 134 MPFROMLONG(1L)); 135 135 if (!pCI) { … … 137 137 return FALSE; 138 138 } 139 if (!rc) {139 if (!rc) { 140 140 ullCurDirBytes = pFFB->cbFile; 141 141 ullCurDirBytes += CBLIST_TO_EASIZE(pFFB->cbList); … … 148 148 pCI->attrFile = 0L; 149 149 } 150 else 151 { 150 else { 152 151 free(pFFB); 153 152 Dos_Error(MB_ENTER, … … 155 154 HWND_DESKTOP, 156 155 pszSrcFile, 157 __LINE__, 158 GetPString(IDS_CANTFINDDIRTEXT), 159 pszFileName); 156 __LINE__, GetPString(IDS_CANTFINDDIRTEXT), pszFileName); 160 157 return FALSE; 161 158 } 162 159 163 if (strlen(pszFileName) < 4 || top)164 strcpy(pCI->szFileName, pszFileName);160 if (strlen(pszFileName) < 4 || top) 161 strcpy(pCI->szFileName, pszFileName); 165 162 else { 166 p = strrchr(pszFileName, '\\');167 if (!p)163 p = strrchr(pszFileName, '\\'); 164 if (!p) 168 165 p = pszFileName; 169 166 else 170 167 p++; 171 sp = (strchr(pszFileName, ' ') != NULL) ? "\"" : NullStr;168 sp = (strchr(pszFileName, ' ') != NULL) ? "\"" : NullStr; 172 169 pp = pCI->szFileName; 173 if (*sp) {170 if (*sp) { 174 171 *pp = *sp; 175 172 pp++; 176 173 *pp = 0; 177 174 } 178 strcpy(pp, p);179 if (*sp)180 strcat(pp, sp);175 strcpy(pp, p); 176 if (*sp) 177 strcat(pp, sp); 181 178 } 182 179 pCI->pszFileName = pCI->szFileName + strlen(pCI->szFileName); 183 180 pCI->rc.pszIcon = pCI->pszLongname; 184 181 pCI->rc.flRecordAttr |= CRA_RECORDREADONLY; 185 if (fForceUpper)182 if (fForceUpper) 186 183 strupr(pCI->szFileName); 187 else if (fForceLower)184 else if (fForceLower) 188 185 strlwr(pCI->szFileName); 189 memset(&ri, 0,sizeof(RECORDINSERT));190 ri.cb 191 ri.pRecordOrder = (PRECORDCORE)CMA_END;192 ri.pRecordParent = (PRECORDCORE)pciParent;193 ri.zOrder = (USHORT)CMA_TOP;194 ri.cRecordsInsert 195 ri.fInvalidateRecord 186 memset(&ri, 0, sizeof(RECORDINSERT)); 187 ri.cb = sizeof(RECORDINSERT); 188 ri.pRecordOrder = (PRECORDCORE) CMA_END; 189 ri.pRecordParent = (PRECORDCORE) pciParent; 190 ri.zOrder = (USHORT) CMA_TOP; 191 ri.cRecordsInsert = 1L; 192 ri.fInvalidateRecord = TRUE; 196 193 //printf("CM_INSERTRECORD\n"); 197 if (!WinSendMsg(hwndCnr,CM_INSERTRECORD,MPFROMP(pCI),MPFROMP(&ri))) {194 if (!WinSendMsg(hwndCnr, CM_INSERTRECORD, MPFROMP(pCI), MPFROMP(&ri))) { 198 195 //printf("Insert failed\n"); 199 196 free(pFFB); … … 203 200 nm = 1L; 204 201 //printf("FIND2\n"); 205 rc = DosFindFirst(maskstr, &hdir,202 rc = DosFindFirst(maskstr, &hdir, 206 203 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | 207 204 FILE_SYSTEM | FILE_HIDDEN | FILE_DIRECTORY, 208 pFFB, 209 sizeof(FILEFINDBUF4), 210 &nm, 211 FIL_QUERYEASIZE); 212 if(!rc) 213 { 214 register PBYTE fb = (PBYTE)pFFB; 215 FILEFINDBUF4 *pffbFile; 216 ULONG x; 217 218 while(!rc) 219 { 205 pFFB, sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE); 206 if (!rc) { 207 register PBYTE fb = (PBYTE) pFFB; 208 FILEFINDBUF4 *pffbFile; 209 ULONG x; 210 211 while (!rc) { 220 212 priority_normal(); 221 213 //printf("Found %lu\n",nm); 222 for(x = 0L;x < nm;x++) 223 { 224 pffbFile = (FILEFINDBUF4 *)fb; 214 for (x = 0L; x < nm; x++) { 215 pffbFile = (FILEFINDBUF4 *) fb; 225 216 //printf("%s\n",pffbFile->achName); 226 217 //fflush(stdout); … … 233 224 ullCurDirBytes += CBLIST_TO_EASIZE(pffbFile->cbList) & 0x3ff; 234 225 235 if (!(pffbFile->attrFile & FILE_DIRECTORY))226 if (!(pffbFile->attrFile & FILE_DIRECTORY)) 236 227 pCI->attrFile++; // Bump file count 237 if (*pchStopFlag)228 if (*pchStopFlag) 238 229 break; 239 if (pffbFile->attrFile & FILE_DIRECTORY) {230 if (pffbFile->attrFile & FILE_DIRECTORY) { 240 231 // Recurse into subdir 241 strcpy(pEndMask,pffbFile->achName); // Append dirname to base dirname 242 if(!*pchStopFlag) 243 { 244 ProcessDir(hwndCnr,maskstr,pCI,pchStopFlag,FALSE,&ull); 232 strcpy(pEndMask, pffbFile->achName); // Append dirname to base dirname 233 if (!*pchStopFlag) { 234 ProcessDir(hwndCnr, maskstr, pCI, pchStopFlag, FALSE, &ull); 245 235 ullSubDirBytes += ull; 246 236 } 247 237 } 248 238 } 249 if (!pffbFile->oNextEntryOffset)239 if (!pffbFile->oNextEntryOffset) 250 240 break; 251 241 fb += pffbFile->oNextEntryOffset; 252 } 253 if (*pchStopFlag)242 } // for matches 243 if (*pchStopFlag) 254 244 break; 255 245 DosSleep(0L); 256 nm = 1L; /* FilesToGet */257 rc = DosFindNext(hdir, pFFB,sizeof(FILEFINDBUF4) ,&nm);258 } 246 nm = 1L; /* FilesToGet */ 247 rc = DosFindNext(hdir, pFFB, sizeof(FILEFINDBUF4), &nm); 248 } // while more found 259 249 DosFindClose(hdir); 260 250 priority_normal(); … … 264 254 265 255 pCI->cbFile = ullCurDirBytes; 266 pCI->easize = ullSubDirBytes; // hack cough267 WinSendMsg(hwndCnr, CM_INVALIDATERECORD,MPFROMP(&pCI),268 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));256 pCI->easize = ullSubDirBytes; // hack cough 257 WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPFROMP(&pCI), 258 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED)); 269 259 270 260 *pullTotalBytes = ullCurDirBytes + ullSubDirBytes; … … 272 262 } 273 263 274 275 static VOID FillInRecSizes (HWND hwndCnr,PCNRITEM pciParent,ULONGLONG ullTotalBytes,276 CHAR *pchStopFlag,BOOL isroot)264 static VOID FillInRecSizes(HWND hwndCnr, PCNRITEM pciParent, 265 ULONGLONG ullTotalBytes, CHAR * pchStopFlag, 266 BOOL isroot) 277 267 { 278 268 PCNRITEM pCI = pciParent; 279 SHORT 280 281 if (pCI) {282 283 float 284 CHAR 285 CHAR 286 CHAR 287 CHAR 269 SHORT attrib = CMA_FIRSTCHILD; 270 271 if (pCI) { 272 273 float fltPct = 0.0; 274 CHAR szCurDir[80]; 275 CHAR szSubDir[80]; 276 CHAR szAllDir[80]; 277 CHAR szBar[80]; 288 278 289 279 // cbFile = currect directory usage in bytes 290 280 // easize = subdirectory usage in bytes 291 CommaFmtULL(szCurDir, sizeof(szCurDir),pCI->cbFile,'K');281 CommaFmtULL(szCurDir, sizeof(szCurDir), pCI->cbFile, 'K'); 292 282 *szBar = 0; 293 283 294 if (ullTotalBytes) 295 { 296 register UINT cBar; 297 298 if(isroot) 299 { 284 if (ullTotalBytes) { 285 register UINT cBar; 286 287 if (isroot) { 300 288 FSALLOCATE fsa; 301 APIRET 302 303 memset(&fsa, 0,sizeof(fsa));304 rc = DosQueryFSInfo(toupper(*pCI->szFileName) - '@', FSIL_ALLOC,&fsa,289 APIRET rc; 290 291 memset(&fsa, 0, sizeof(fsa)); 292 rc = DosQueryFSInfo(toupper(*pCI->szFileName) - '@', FSIL_ALLOC, &fsa, 305 293 sizeof(FSALLOCATE)); 306 if (!rc) 307 { 294 if (!rc) { 308 295 fltPct = (ullTotalBytes * 100.0) / 309 ((float)fsa.cUnit *(fsa.cSectorUnit * fsa.cbSector));296 ((float)fsa.cUnit * (fsa.cSectorUnit * fsa.cbSector)); 310 297 } 311 pCI->szLongname[1] = 1; // Flag root - hack cough298 pCI->szLongname[1] = 1; // Flag root - hack cough 312 299 } 313 300 else 314 301 fltPct = (((float)pCI->cbFile + pCI->easize) * 100.0) / ullTotalBytes; 315 302 316 cBar = (UINT) fltPct / 2;303 cBar = (UINT) fltPct / 2; 317 304 if (cBar) 318 305 memset(szBar, '#', cBar); 319 if (cBar * 2 != (UINT)fltPct) {306 if (cBar * 2 != (UINT) fltPct) { 320 307 szBar[cBar] = '='; 321 308 cBar++; … … 326 313 } 327 314 328 pCI->flags = (ULONG) fltPct;329 CommaFmtULL(szSubDir, sizeof(szSubDir),pCI->easize,'K');330 CommaFmtULL(szAllDir, sizeof(szAllDir),pCI->cbFile + pCI->easize,'K');315 pCI->flags = (ULONG) fltPct; 316 CommaFmtULL(szSubDir, sizeof(szSubDir), pCI->easize, 'K'); 317 CommaFmtULL(szAllDir, sizeof(szAllDir), pCI->cbFile + pCI->easize, 'K'); 331 318 sprintf(&pCI->szFileName[strlen(pCI->szFileName)], 332 319 " %s + %s = %s (%.02lf%%%s)\r%s", … … 334 321 szSubDir, 335 322 szAllDir, 336 fltPct, 337 isroot ? GetPString(IDS_OFDRIVETEXT) : NullStr, 338 szBar); 323 fltPct, isroot ? GetPString(IDS_OFDRIVETEXT) : NullStr, szBar); 339 324 WinSendMsg(hwndCnr, 340 CM_INVALIDATERECORD, 341 MPFROMP(&pCI), 342 MPFROM2SHORT(1,0)); 325 CM_INVALIDATERECORD, MPFROMP(&pCI), MPFROM2SHORT(1, 0)); 343 326 isroot = FALSE; 344 327 } 345 328 else 346 329 attrib = CMA_FIRST; 347 pCI = (PCNRITEM) WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(pCI),348 MPFROM2SHORT(attrib,CMA_ITEMORDER));349 while (pCI && (INT)pCI != -1) {350 if (*pchStopFlag)330 pCI = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pCI), 331 MPFROM2SHORT(attrib, CMA_ITEMORDER)); 332 while (pCI && (INT) pCI != -1) { 333 if (*pchStopFlag) 351 334 break; 352 FillInRecSizes(hwndCnr, pCI,ullTotalBytes,pchStopFlag,isroot);335 FillInRecSizes(hwndCnr, pCI, ullTotalBytes, pchStopFlag, isroot); 353 336 isroot = FALSE; 354 pCI = (PCNRITEM) WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(pCI),355 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));337 pCI = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pCI), 338 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 356 339 } 357 340 } 358 341 359 360 static VOID PrintToFile (HWND hwndCnr,ULONG indent,PCNRITEM pciParent, 361 FILE *fp) 342 static VOID PrintToFile(HWND hwndCnr, ULONG indent, PCNRITEM pciParent, 343 FILE * fp) 362 344 { 363 PCNRITEM 345 PCNRITEM pci; 364 346 register CHAR *p; 365 347 366 if (!pciParent) {367 pciParent = WinSendMsg(hwndCnr, CM_QUERYRECORD,MPFROMP(NULL),368 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));348 if (!pciParent) { 349 pciParent = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(NULL), 350 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 369 351 indent = 0; 370 352 } 371 if (pciParent) {372 p = strchr(pciParent->szFileName, '\r');373 if (p)353 if (pciParent) { 354 p = strchr(pciParent->szFileName, '\r'); 355 if (p) 374 356 *p = 0; 375 fprintf(fp, "%*.*s%s %lu %s%s\n",376 indent * 2, indent * 2," ",357 fprintf(fp, "%*.*s%s %lu %s%s\n", 358 indent * 2, indent * 2, " ", 377 359 pciParent->szFileName, 378 360 pciParent->attrFile, 379 GetPString(IDS_FILETEXT), 380 &"s"[pciParent->attrFile == 1]); 381 if(p) 361 GetPString(IDS_FILETEXT), &"s"[pciParent->attrFile == 1]); 362 if (p) 382 363 *p = '\r'; 383 if(pciParent->rc.flRecordAttr & CRA_EXPANDED) { 384 pci = (PCNRITEM)WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(pciParent), 385 MPFROM2SHORT(CMA_FIRSTCHILD,CMA_ITEMORDER)); 386 while(pci && (INT)pci != -1) { 364 if (pciParent->rc.flRecordAttr & CRA_EXPANDED) { 365 pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pciParent), 366 MPFROM2SHORT(CMA_FIRSTCHILD, 367 CMA_ITEMORDER)); 368 while (pci && (INT) pci != -1) { 387 369 DosSleep(0L); 388 PrintToFile(hwndCnr, indent + 1,pci,fp);389 pci = (PCNRITEM) WinSendMsg(hwndCnr,CM_QUERYRECORD,MPFROMP(pci),390 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));370 PrintToFile(hwndCnr, indent + 1, pci, fp); 371 pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci), 372 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 391 373 } 392 374 } … … 394 376 } 395 377 396 397 static VOID FillCnrThread (VOID *args) 378 static VOID FillCnrThread(VOID * args) 398 379 { 399 HAB 400 HMQ 401 DIRSIZE *dirsize = (DIRSIZE *)args;402 HWND 403 ULONGLONG 404 405 if (!dirsize)380 HAB hab; 381 HMQ hmq; 382 DIRSIZE *dirsize = (DIRSIZE *) args; 383 HWND hwndCnr; 384 ULONGLONG ull; 385 386 if (!dirsize) 406 387 return; 407 388 hwndCnr = dirsize->hwndCnr; … … 411 392 // priority_normal(); 412 393 hab = WinInitialize(0); 413 if(hab) 414 { 415 hmq = WinCreateMsgQueue(hab,0); 416 if(hmq) 417 { 418 WinCancelShutdown(hmq,TRUE); 419 ProcessDir(hwndCnr,dirsize->pszFileName, 420 (PCNRITEM)NULL,dirsize->pchStopFlag,TRUE,&ull); 394 if (hab) { 395 hmq = WinCreateMsgQueue(hab, 0); 396 if (hmq) { 397 WinCancelShutdown(hmq, TRUE); 398 ProcessDir(hwndCnr, dirsize->pszFileName, 399 (PCNRITEM) NULL, dirsize->pchStopFlag, TRUE, &ull); 421 400 DosPostEventSem(CompactSem); 422 WinEnableWindowUpdate(hwndCnr, FALSE);423 FillInRecSizes(hwndCnr, NULL,ull,dirsize->pchStopFlag,TRUE);424 WinEnableWindowUpdate(hwndCnr, TRUE);425 WinSendMsg(hwndCnr, CM_INVALIDATERECORD,MPVOID,426 MPFROM2SHORT(0, CMA_ERASE | CMA_TEXTCHANGED));401 WinEnableWindowUpdate(hwndCnr, FALSE); 402 FillInRecSizes(hwndCnr, NULL, ull, dirsize->pchStopFlag, TRUE); 403 WinEnableWindowUpdate(hwndCnr, TRUE); 404 WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPVOID, 405 MPFROM2SHORT(0, CMA_ERASE | CMA_TEXTCHANGED)); 427 406 WinDestroyMsgQueue(hmq); 428 407 } 429 408 WinTerminate(hab); 430 409 } 431 PostMsg(WinQueryWindow(hwndCnr,QW_PARENT), 432 UM_CONTAINER_FILLED, 433 MPVOID,MPVOID); 410 PostMsg(WinQueryWindow(hwndCnr, QW_PARENT), 411 UM_CONTAINER_FILLED, MPVOID, MPVOID); 434 412 free(dirsize); 435 413 } 436 414 437 438 MRESULT EXPENTRY DirSizeProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) 415 MRESULT EXPENTRY DirSizeProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 439 416 { 440 417 tState *pState; … … 443 420 CHAR sz[66]; 444 421 445 switch(msg) { 446 case WM_INITDLG: 447 if(!mp2) { 448 WinDismissDlg(hwnd,0); 422 switch (msg) { 423 case WM_INITDLG: 424 if (!mp2) { 425 WinDismissDlg(hwnd, 0); 426 break; 427 } 428 pState = xmallocz(sizeof(tState), pszSrcFile, __LINE__); 429 if (!pState) { 430 WinDismissDlg(hwnd, 0); 431 break; 432 } 433 strcpy(pState->szDirName, (CHAR *) mp2); 434 WinSetWindowPtr(hwnd, 0, (PVOID) pState); 435 pState->hptr = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DIRSIZE_ICON); 436 WinDefDlgProc(hwnd, WM_SETICON, MPFROMLONG(pState->hptr), MPVOID); 437 { 438 CHAR s[CCHMAXPATH + 81]; 439 440 sprintf(s, GetPString(IDS_DIRSIZETITLETEXT), pState->szDirName); 441 WinSetWindowText(hwnd, s); 442 } 443 { 444 DIRSIZE *dirsize; 445 446 dirsize = xmalloc(sizeof(DIRSIZE), pszSrcFile, __LINE__); 447 if (!dirsize) { 448 WinDismissDlg(hwnd, 0); 449 449 break; 450 450 } 451 pState = xmallocz(sizeof(tState),pszSrcFile,__LINE__); 452 if(!pState) { 453 WinDismissDlg(hwnd,0); 451 dirsize->pchStopFlag = (CHAR *) & pState->chStopFlag; 452 dirsize->pszFileName = pState->szDirName; 453 dirsize->hwndCnr = WinWindowFromID(hwnd, DSZ_CNR); 454 if (_beginthread(FillCnrThread, NULL, 122880L * 5L, (PVOID) dirsize) == 455 -1) { 456 Runtime_Error(pszSrcFile, __LINE__, 457 GetPString(IDS_COULDNTSTARTTHREADTEXT)); 458 free(dirsize); 459 WinDismissDlg(hwnd, 0); 454 460 break; 455 461 } 456 strcpy(pState->szDirName,(CHAR *)mp2); 457 WinSetWindowPtr(hwnd,0,(PVOID)pState); 458 pState->hptr = WinLoadPointer(HWND_DESKTOP,FM3ModHandle,DIRSIZE_ICON); 459 WinDefDlgProc(hwnd,WM_SETICON,MPFROMLONG(pState->hptr),MPVOID); 460 { 461 CHAR s[CCHMAXPATH + 81]; 462 463 sprintf(s, 464 GetPString(IDS_DIRSIZETITLETEXT), 465 pState->szDirName); 466 WinSetWindowText(hwnd,s); 467 } 468 { 469 DIRSIZE *dirsize; 470 471 dirsize = xmalloc(sizeof(DIRSIZE),pszSrcFile,__LINE__); 472 if(!dirsize) { 473 WinDismissDlg(hwnd,0); 474 break; 462 pState->working = TRUE; 463 WinEnableWindow(WinWindowFromID(hwnd, DSZ_COLLAPSE), FALSE); 464 WinEnableWindow(WinWindowFromID(hwnd, DSZ_EXPAND), FALSE); 465 WinEnableWindow(WinWindowFromID(hwnd, DSZ_PRINT), FALSE); 466 } 467 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); 468 break; 469 470 case UM_SETUP: 471 { 472 CNRINFO cnri; 473 FSALLOCATE fsa; 474 APIRET rc; 475 476 memset(&cnri, 0, sizeof(CNRINFO)); 477 cnri.cb = sizeof(CNRINFO); 478 WinSendDlgItemMsg(hwnd, DSZ_CNR, CM_QUERYCNRINFO, 479 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO))); 480 cnri.cyLineSpacing = 0; 481 cnri.cxTreeIndent = 12L; 482 cnri.flWindowAttr = CV_TREE | CV_FLOW | CA_TREELINE | CA_OWNERDRAW; 483 WinSendDlgItemMsg(hwnd, DSZ_CNR, CM_SETCNRINFO, MPFROMP(&cnri), 484 MPFROMLONG(CMA_FLWINDOWATTR | CMA_TREEICON | 485 CMA_LINESPACING | CMA_CXTREEINDENT)); 486 pState = INSTDATA(hwnd); 487 if (pState && isalpha(*pState->szDirName)) { 488 memset(&fsa, 0, sizeof(fsa)); 489 rc = 490 DosQueryFSInfo(toupper(*pState->szDirName) - '@', FSIL_ALLOC, &fsa, 491 sizeof(FSALLOCATE)); 492 if (!rc) { 493 494 CHAR s[132], tf[80], tb[80], tu[80]; 495 496 CommaFmtULL(tf, sizeof(tf), 497 (ULONGLONG) fsa.cUnitAvail * 498 (fsa.cSectorUnit * fsa.cbSector), 'M'); 499 CommaFmtULL(tb, sizeof(tb), 500 (ULONGLONG) fsa.cUnit * 501 (fsa.cSectorUnit * fsa.cbSector), 'M'); 502 CommaFmtULL(tu, sizeof(tu), 503 (ULONGLONG) (fsa.cUnit - fsa.cUnitAvail) * 504 (fsa.cSectorUnit * fsa.cbSector), 'M'); 505 sprintf(s, GetPString(IDS_FREESPACETEXT), tf, tb, tu); 506 WinSetDlgItemText(hwnd, DSZ_FREESPACE, s); 475 507 } 476 dirsize->pchStopFlag = (CHAR *)&pState->chStopFlag; 477 dirsize->pszFileName = pState->szDirName; 478 dirsize->hwndCnr = WinWindowFromID(hwnd,DSZ_CNR); 479 if(_beginthread(FillCnrThread,NULL,122880L * 5L,(PVOID)dirsize) == -1) { 480 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 481 free(dirsize); 482 WinDismissDlg(hwnd,0); 483 break; 484 } 485 pState->working = TRUE; 486 WinEnableWindow(WinWindowFromID(hwnd,DSZ_COLLAPSE),FALSE); 487 WinEnableWindow(WinWindowFromID(hwnd,DSZ_EXPAND),FALSE); 488 WinEnableWindow(WinWindowFromID(hwnd,DSZ_PRINT),FALSE); 489 } 490 PostMsg(hwnd,UM_SETUP,MPVOID,MPVOID); 491 break; 492 493 case UM_SETUP: 494 { 495 CNRINFO cnri; 496 FSALLOCATE fsa; 497 APIRET rc; 498 499 memset(&cnri,0,sizeof(CNRINFO)); 500 cnri.cb = sizeof(CNRINFO); 501 WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_QUERYCNRINFO, 502 MPFROMP(&cnri),MPFROMLONG(sizeof(CNRINFO))); 503 cnri.cyLineSpacing = 0; 504 cnri.cxTreeIndent = 12L; 505 cnri.flWindowAttr = CV_TREE | CV_FLOW | CA_TREELINE | CA_OWNERDRAW; 506 WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_SETCNRINFO,MPFROMP(&cnri), 507 MPFROMLONG(CMA_FLWINDOWATTR | CMA_TREEICON | 508 CMA_LINESPACING | CMA_CXTREEINDENT)); 509 pState = INSTDATA(hwnd); 510 if(pState && isalpha(*pState->szDirName)) { 511 memset(&fsa,0,sizeof(fsa)); 512 rc = DosQueryFSInfo(toupper(*pState->szDirName) - '@',FSIL_ALLOC,&fsa, 513 sizeof(FSALLOCATE)); 514 if (!rc) 515 { 516 517 CHAR s[132],tf[80],tb[80],tu[80]; 518 519 CommaFmtULL(tf,sizeof(tf), 520 (ULONGLONG)fsa.cUnitAvail * 521 (fsa.cSectorUnit * fsa.cbSector),'M'); 522 CommaFmtULL(tb,sizeof(tb), 523 (ULONGLONG)fsa.cUnit * 524 (fsa.cSectorUnit * fsa.cbSector),'M'); 525 CommaFmtULL(tu,sizeof(tu), 526 (ULONGLONG)(fsa.cUnit - fsa.cUnitAvail) * 527 (fsa.cSectorUnit * fsa.cbSector),'M'); 528 sprintf(s, 529 GetPString(IDS_FREESPACETEXT), 530 tf, 531 tb, 532 tu); 533 WinSetDlgItemText(hwnd, 534 DSZ_FREESPACE, 535 s); 536 } 537 else 538 WinSetDlgItemText(hwnd, 539 DSZ_FREESPACE, 540 GetPString(IDS_FREESPACEUTEXT)); 541 } 542 } 508 else 509 WinSetDlgItemText(hwnd, 510 DSZ_FREESPACE, GetPString(IDS_FREESPACEUTEXT)); 511 } 512 } 513 return 0; 514 515 case UM_CONTAINER_FILLED: 516 pState = INSTDATA(hwnd); 517 if (!pState || pState->dying) { 518 if (pState) 519 pState->working = FALSE; 520 WinDismissDlg(hwnd, 0); 543 521 return 0; 544 545 case UM_CONTAINER_FILLED: 546 pState = INSTDATA(hwnd); 547 if (!pState || pState->dying) { 548 if (pState) 549 pState->working = FALSE; 550 WinDismissDlg(hwnd,0); 551 return 0; 552 } 553 pState->working = FALSE; 554 WinEnableWindow(WinWindowFromID(hwnd,DSZ_COLLAPSE),TRUE); 555 WinEnableWindow(WinWindowFromID(hwnd,DSZ_EXPAND),TRUE); 556 WinEnableWindow(WinWindowFromID(hwnd,DSZ_PRINT),TRUE); 557 558 pci = WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_QUERYRECORD,MPVOID, 559 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER)); 560 if(pci && (INT)pci != -1) 561 WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_EXPANDTREE,MPFROMP(pci),MPVOID); 562 *sz = 0; 563 pci = WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_QUERYRECORDEMPHASIS, 564 MPFROMLONG(CMA_FIRST), 565 MPFROMSHORT(CRA_CURSORED)); 566 if (pci && (INT)pci != -1) 567 { 568 commafmt(szBytes,sizeof(szBytes),pci->attrFile); 569 sprintf(sz, 570 "%s %s%s", 571 szBytes, 572 GetPString(IDS_FILETEXT), 573 &"s"[pci->attrFile == 1]); 574 } 575 WinSetDlgItemText(hwnd,DSZ_NUMFILES,sz); 576 577 WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_SORTRECORD,MPFROMP(SortSizeCnr), 578 MPVOID); 579 DosBeep(500,25); // Wake up user 580 return 0; 581 582 case WM_ADJUSTWINDOWPOS: 583 PostMsg(hwnd,UM_STRETCH,MPVOID,MPVOID); 584 break; 585 586 case UM_STRETCH: 587 { 588 SWP swpC,swp; 589 590 WinQueryWindowPos(hwnd,&swp); 591 if(!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) { 592 WinQueryWindowPos(WinWindowFromID(hwnd,DSZ_CNR),&swpC); 593 WinSetWindowPos(WinWindowFromID(hwnd,DSZ_CNR),HWND_TOP, 594 SysVal(SV_CXSIZEBORDER), 595 swpC.y, 596 swp.cx - (SysVal(SV_CXSIZEBORDER) * 2), 597 (swp.cy - swpC.y) - (SysVal(SV_CYTITLEBAR) + 598 SysVal(SV_CYSIZEBORDER)), 599 SWP_MOVE | SWP_SIZE); 600 } 601 } 602 return 0; 603 604 case WM_DRAWITEM: 605 if(mp2) { 606 607 OWNERITEM *oi = mp2; 608 CNRDRAWITEMINFO *cnd; 609 PCNRITEM pci; 610 611 if(oi->idItem == CMA_TEXT) { 612 cnd = (CNRDRAWITEMINFO *)oi->hItem; 613 if(cnd) { 614 pci = (PCNRITEM)cnd->pRecord; 615 if(pci) { 616 617 POINTL aptl[TXTBOX_COUNT],ptl; 618 CHAR *p; 619 LONG clr,x; 620 621 p = strchr(pci->szFileName,'\r'); 622 if(p) { 623 /* draw text */ 624 if (!pci->cbFile) /* no size */ 625 GpiSetColor(oi->hps,CLR_DARKGRAY); 626 else if (!pci->easize) /* no size below */ 627 GpiSetColor(oi->hps,CLR_DARKBLUE); 522 } 523 pState->working = FALSE; 524 WinEnableWindow(WinWindowFromID(hwnd, DSZ_COLLAPSE), TRUE); 525 WinEnableWindow(WinWindowFromID(hwnd, DSZ_EXPAND), TRUE); 526 WinEnableWindow(WinWindowFromID(hwnd, DSZ_PRINT), TRUE); 527 528 pci = WinSendDlgItemMsg(hwnd, DSZ_CNR, CM_QUERYRECORD, MPVOID, 529 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 530 if (pci && (INT) pci != -1) 531 WinSendDlgItemMsg(hwnd, DSZ_CNR, CM_EXPANDTREE, MPFROMP(pci), MPVOID); 532 *sz = 0; 533 pci = WinSendDlgItemMsg(hwnd, DSZ_CNR, CM_QUERYRECORDEMPHASIS, 534 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED)); 535 if (pci && (INT) pci != -1) { 536 commafmt(szBytes, sizeof(szBytes), pci->attrFile); 537 sprintf(sz, 538 "%s %s%s", 539 szBytes, GetPString(IDS_FILETEXT), &"s"[pci->attrFile == 1]); 540 } 541 WinSetDlgItemText(hwnd, DSZ_NUMFILES, sz); 542 543 WinSendDlgItemMsg(hwnd, DSZ_CNR, CM_SORTRECORD, MPFROMP(SortSizeCnr), 544 MPVOID); 545 DosBeep(500, 25); // Wake up user 546 return 0; 547 548 case WM_ADJUSTWINDOWPOS: 549 PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID); 550 break; 551 552 case UM_STRETCH: 553 { 554 SWP swpC, swp; 555 556 WinQueryWindowPos(hwnd, &swp); 557 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) { 558 WinQueryWindowPos(WinWindowFromID(hwnd, DSZ_CNR), &swpC); 559 WinSetWindowPos(WinWindowFromID(hwnd, DSZ_CNR), HWND_TOP, 560 SysVal(SV_CXSIZEBORDER), 561 swpC.y, 562 swp.cx - (SysVal(SV_CXSIZEBORDER) * 2), 563 (swp.cy - swpC.y) - (SysVal(SV_CYTITLEBAR) + 564 SysVal(SV_CYSIZEBORDER)), 565 SWP_MOVE | SWP_SIZE); 566 } 567 } 568 return 0; 569 570 case WM_DRAWITEM: 571 if (mp2) { 572 573 OWNERITEM *oi = mp2; 574 CNRDRAWITEMINFO *cnd; 575 PCNRITEM pci; 576 577 if (oi->idItem == CMA_TEXT) { 578 cnd = (CNRDRAWITEMINFO *) oi->hItem; 579 if (cnd) { 580 pci = (PCNRITEM) cnd->pRecord; 581 if (pci) { 582 583 POINTL aptl[TXTBOX_COUNT], ptl; 584 CHAR *p; 585 LONG clr, x; 586 587 p = strchr(pci->szFileName, '\r'); 588 if (p) { 589 /* draw text */ 590 if (!pci->cbFile) /* no size */ 591 GpiSetColor(oi->hps, CLR_DARKGRAY); 592 else if (!pci->easize) /* no size below */ 593 GpiSetColor(oi->hps, CLR_DARKBLUE); 594 else 595 GpiSetColor(oi->hps, CLR_BLACK); 596 GpiSetBackMix(oi->hps, BM_LEAVEALONE); 597 GpiSetMix(oi->hps, FM_OVERPAINT); 598 *p = 0; 599 GpiQueryTextBox(oi->hps, strlen(pci->szFileName), 600 pci->szFileName, TXTBOX_COUNT, aptl); 601 ptl.x = oi->rclItem.xLeft; 602 ptl.y = (oi->rclItem.yTop - aptl[TXTBOX_TOPRIGHT].y); 603 GpiMove(oi->hps, &ptl); 604 GpiCharString(oi->hps, strlen(pci->szFileName), 605 pci->szFileName); 606 *p = '\r'; 607 608 /* draw the graph box */ 609 GpiQueryTextBox(oi->hps, 1, "#", TXTBOX_COUNT, aptl); 610 /* draw black outline */ 611 GpiSetColor(oi->hps, CLR_BLACK); 612 ptl.x = oi->rclItem.xLeft; 613 ptl.y = oi->rclItem.yBottom + 2; 614 GpiMove(oi->hps, &ptl); 615 ptl.x = oi->rclItem.xLeft + 101; 616 ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y); 617 GpiBox(oi->hps, DRO_OUTLINE, &ptl, 0, 0); 618 /* fill with gray */ 619 GpiSetColor(oi->hps, CLR_PALEGRAY); 620 ptl.x = oi->rclItem.xLeft + 1; 621 ptl.y = oi->rclItem.yBottom + 3; 622 GpiMove(oi->hps, &ptl); 623 ptl.x = oi->rclItem.xLeft + 100; 624 ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1; 625 GpiBox(oi->hps, DRO_OUTLINEFILL, &ptl, 0, 0); 626 627 /* draw shadow at bottom & right sides */ 628 GpiSetColor(oi->hps, CLR_DARKGRAY); 629 ptl.x = oi->rclItem.xLeft + 1; 630 ptl.y = oi->rclItem.yBottom + 3; 631 GpiMove(oi->hps, &ptl); 632 ptl.x = oi->rclItem.xLeft + 100; 633 GpiLine(oi->hps, &ptl); 634 ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1; 635 GpiLine(oi->hps, &ptl); 636 637 /* draw highlight at top and left sides */ 638 GpiSetColor(oi->hps, CLR_WHITE); 639 ptl.x = oi->rclItem.xLeft + 1; 640 GpiLine(oi->hps, &ptl); 641 ptl.y = oi->rclItem.yBottom + 3; 642 GpiLine(oi->hps, &ptl); 643 644 /* draw shadow of box */ 645 GpiSetColor(oi->hps, CLR_DARKGRAY); 646 ptl.x = oi->rclItem.xLeft + 2; 647 ptl.y = oi->rclItem.yBottom; 648 GpiMove(oi->hps, &ptl); 649 ptl.x = oi->rclItem.xLeft + 103; 650 GpiLine(oi->hps, &ptl); 651 ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 2; 652 GpiLine(oi->hps, &ptl); 653 ptl.x--; 654 GpiMove(oi->hps, &ptl); 655 ptl.y = oi->rclItem.yBottom + 1; 656 GpiLine(oi->hps, &ptl); 657 ptl.x = oi->rclItem.xLeft + 2; 658 GpiLine(oi->hps, &ptl); 659 660 /* fill box with graph bar, flags is integer % */ 661 if (pci->flags) { 662 if (pci->szLongname[1] == 1) /* is root record */ 663 GpiSetColor(oi->hps, CLR_DARKGREEN); 628 664 else 629 GpiSetColor(oi->hps,CLR_BLACK); 630 GpiSetBackMix(oi->hps,BM_LEAVEALONE); 631 GpiSetMix(oi->hps,FM_OVERPAINT); 632 *p = 0; 633 GpiQueryTextBox(oi->hps,strlen(pci->szFileName), 634 pci->szFileName,TXTBOX_COUNT,aptl); 635 ptl.x = oi->rclItem.xLeft; 636 ptl.y = (oi->rclItem.yTop - aptl[TXTBOX_TOPRIGHT].y); 637 GpiMove(oi->hps,&ptl); 638 GpiCharString(oi->hps,strlen(pci->szFileName), 639 pci->szFileName); 640 *p = '\r'; 641 642 /* draw the graph box */ 643 GpiQueryTextBox(oi->hps,1,"#",TXTBOX_COUNT,aptl); 644 /* draw black outline */ 645 GpiSetColor(oi->hps,CLR_BLACK); 646 ptl.x = oi->rclItem.xLeft; 647 ptl.y = oi->rclItem.yBottom + 2; 648 GpiMove(oi->hps,&ptl); 649 ptl.x = oi->rclItem.xLeft + 101; 650 ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y); 651 GpiBox(oi->hps,DRO_OUTLINE,&ptl,0,0); 652 /* fill with gray */ 653 GpiSetColor(oi->hps,CLR_PALEGRAY); 665 GpiSetColor(oi->hps, CLR_RED); 654 666 ptl.x = oi->rclItem.xLeft + 1; 655 667 ptl.y = oi->rclItem.yBottom + 3; 656 GpiMove(oi->hps, &ptl);657 ptl.x = oi->rclItem.xLeft + 100;668 GpiMove(oi->hps, &ptl); 669 ptl.x = oi->rclItem.xLeft + pci->flags; 658 670 ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1; 659 GpiBox(oi->hps,DRO_OUTLINEFILL,&ptl,0,0); 660 661 /* draw shadow at bottom & right sides */ 662 GpiSetColor(oi->hps,CLR_DARKGRAY); 663 ptl.x = oi->rclItem.xLeft + 1; 664 ptl.y = oi->rclItem.yBottom + 3; 665 GpiMove(oi->hps,&ptl); 666 ptl.x = oi->rclItem.xLeft + 100; 667 GpiLine(oi->hps,&ptl); 668 ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1; 669 GpiLine(oi->hps,&ptl); 670 671 /* draw highlight at top and left sides */ 672 GpiSetColor(oi->hps,CLR_WHITE); 673 ptl.x = oi->rclItem.xLeft + 1; 674 GpiLine(oi->hps,&ptl); 675 ptl.y = oi->rclItem.yBottom + 3; 676 GpiLine(oi->hps,&ptl); 677 678 /* draw shadow of box */ 679 GpiSetColor(oi->hps,CLR_DARKGRAY); 680 ptl.x = oi->rclItem.xLeft + 2; 681 ptl.y = oi->rclItem.yBottom; 682 GpiMove(oi->hps,&ptl); 683 ptl.x = oi->rclItem.xLeft + 103; 684 GpiLine(oi->hps,&ptl); 685 ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 2; 686 GpiLine(oi->hps,&ptl); 687 ptl.x--; 688 GpiMove(oi->hps,&ptl); 689 ptl.y = oi->rclItem.yBottom + 1; 690 GpiLine(oi->hps,&ptl); 691 ptl.x = oi->rclItem.xLeft + 2; 692 GpiLine(oi->hps,&ptl); 693 694 /* fill box with graph bar, flags is integer % */ 695 if(pci->flags) { 696 if(pci->szLongname[1] == 1) /* is root record */ 697 GpiSetColor(oi->hps,CLR_DARKGREEN); 698 else 699 GpiSetColor(oi->hps,CLR_RED); 671 GpiBox(oi->hps, DRO_OUTLINEFILL, &ptl, 0, 0); 672 673 /* draw highlights and shadows on graph */ 674 if (pci->szLongname[1] == 1) 675 GpiSetColor(oi->hps, CLR_GREEN); 676 else 677 GpiSetColor(oi->hps, CLR_PALEGRAY); 678 if (pci->flags > 5) { 700 679 ptl.x = oi->rclItem.xLeft + 1; 701 680 ptl.y = oi->rclItem.yBottom + 3; 702 GpiMove(oi->hps,&ptl); 681 GpiMove(oi->hps, &ptl); 682 ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1; 683 GpiLine(oi->hps, &ptl); 684 } 685 else { 686 ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1; 687 GpiMove(oi->hps, &ptl); 688 } 689 ptl.x = oi->rclItem.xLeft + pci->flags; 690 GpiLine(oi->hps, &ptl); 691 if (pci->szLongname[1] != 1) { 692 GpiSetColor(oi->hps, CLR_DARKRED); 693 ptl.x = oi->rclItem.xLeft + 2; 694 ptl.y = oi->rclItem.yBottom + 3; 695 GpiMove(oi->hps, &ptl); 703 696 ptl.x = oi->rclItem.xLeft + pci->flags; 704 ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1; 705 GpiBox(oi->hps,DRO_OUTLINEFILL,&ptl,0,0); 706 707 /* draw highlights and shadows on graph */ 708 if(pci->szLongname[1] == 1) 709 GpiSetColor(oi->hps,CLR_GREEN); 710 else 711 GpiSetColor(oi->hps,CLR_PALEGRAY); 712 if(pci->flags > 5) { 713 ptl.x = oi->rclItem.xLeft + 1; 714 ptl.y = oi->rclItem.yBottom + 3; 715 GpiMove(oi->hps,&ptl); 716 ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1; 717 GpiLine(oi->hps,&ptl); 718 } 719 else { 720 ptl.y = (oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y) - 1; 721 GpiMove(oi->hps,&ptl); 722 } 723 ptl.x = oi->rclItem.xLeft + pci->flags; 724 GpiLine(oi->hps,&ptl); 725 if(pci->szLongname[1] != 1) { 726 GpiSetColor(oi->hps,CLR_DARKRED); 727 ptl.x = oi->rclItem.xLeft + 2; 728 ptl.y = oi->rclItem.yBottom + 3; 729 GpiMove(oi->hps,&ptl); 730 ptl.x = oi->rclItem.xLeft + pci->flags; 731 GpiLine(oi->hps,&ptl); 732 } 697 GpiLine(oi->hps, &ptl); 733 698 } 734 735 /* draw hash marks in box */ 736 GpiSetColor(oi->hps,CLR_WHITE); 737 clr = CLR_WHITE; 738 for(x = 1;x < 10;x++) { 739 if(clr == CLR_WHITE && x * 10 > pci->flags) { 740 clr = CLR_BLACK; 741 GpiSetColor(oi->hps,CLR_BLACK); 742 } 743 ptl.x = (oi->rclItem.xLeft + 1) + (x * 10); 744 ptl.y = oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y - 1; 745 GpiMove(oi->hps,&ptl); 746 switch(x) { 747 case 1: 748 case 3: 749 case 7: 750 case 9: 751 ptl.y -= 1; 752 break; 753 case 5: 754 ptl.y -= 4; 755 break; 756 case 2: 757 case 4: 758 case 6: 759 case 8: 760 ptl.y -= 2; 761 break; 762 } 763 GpiLine(oi->hps,&ptl); 699 } 700 701 /* draw hash marks in box */ 702 GpiSetColor(oi->hps, CLR_WHITE); 703 clr = CLR_WHITE; 704 for (x = 1; x < 10; x++) { 705 if (clr == CLR_WHITE && x * 10 > pci->flags) { 706 clr = CLR_BLACK; 707 GpiSetColor(oi->hps, CLR_BLACK); 764 708 } 765 return MRFROMLONG(TRUE); 709 ptl.x = (oi->rclItem.xLeft + 1) + (x * 10); 710 ptl.y = oi->rclItem.yBottom + aptl[TXTBOX_TOPRIGHT].y - 1; 711 GpiMove(oi->hps, &ptl); 712 switch (x) { 713 case 1: 714 case 3: 715 case 7: 716 case 9: 717 ptl.y -= 1; 718 break; 719 case 5: 720 ptl.y -= 4; 721 break; 722 case 2: 723 case 4: 724 case 6: 725 case 8: 726 ptl.y -= 2; 727 break; 728 } 729 GpiLine(oi->hps, &ptl); 766 730 } 731 return MRFROMLONG(TRUE); 767 732 } 768 733 } 769 734 } 770 735 } 771 return FALSE; 772 773 case WM_CONTROL: 774 switch(SHORT2FROMMP(mp1)) { 775 case CN_ENTER: 776 if(mp2) { 777 778 PCNRITEM pci = (PCNRITEM)((PNOTIFYRECORDENTER)mp2)->pRecord; 779 CHAR pszFileName[CCHMAXPATH],szTemp[CCHMAXPATH]; 780 781 if(pci) { 782 *pszFileName = 0; 783 while(pci && (INT)pci != -1) { 784 memset(szTemp,0,sizeof(szTemp)); 785 strncpy(szTemp,pci->szFileName, 786 pci->pszFileName - pci->szFileName); 787 strrev(szTemp); 788 if(*pszFileName && *szTemp != '\\') 789 strcat(pszFileName,"\\"); 790 strcat(pszFileName,szTemp); 791 pci = WinSendDlgItemMsg(hwnd,DSZ_CNR,CM_QUERYRECORD, 792 MPFROMP(pci), 793 MPFROM2SHORT(CMA_PARENT, 794 CMA_ITEMORDER)); 795 } 796 strrev(pszFileName); 797 if(!fVTreeOpensWPS) 798 OpenDirCnr((HWND)0, 799 (hwndMain) ? hwndMain : HWND_DESKTOP, 800 hwnd, 801 FALSE, 802 pszFileName); 803 else { 804 805 ULONG size = sizeof(ULONG); 806 ULONG flWindowAttr = CV_ICON; 807 CHAR s[33]; 808 809 strcpy(s,"ICON"); 810 PrfQueryProfileData(fmprof,appname,"DirflWindowAttr", 811 (PVOID)&flWindowAttr,&size); 812 if(flWindowAttr & CV_DETAIL) { 813 if(IsRoot(pszFileName)) 814 strcpy(s,"TREE"); 815 else 816 strcpy(s,"DETAILS"); 817 } 818 OpenObject(pszFileName,s,hwnd); 819 } 736 } 737 return FALSE; 738 739 case WM_CONTROL: 740 switch (SHORT2FROMMP(mp1)) { 741 case CN_ENTER: 742 if (mp2) { 743 744 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord; 745 CHAR pszFileName[CCHMAXPATH], szTemp[CCHMAXPATH]; 746 747 if (pci) { 748 *pszFileName = 0; 749 while (pci && (INT) pci != -1) { 750 memset(szTemp, 0, sizeof(szTemp)); 751 strncpy(szTemp, pci->szFileName, 752 pci->pszFileName - pci->szFileName); 753 strrev(szTemp); 754 if (*pszFileName && *szTemp != '\\') 755 strcat(pszFileName, "\\"); 756 strcat(pszFileName, szTemp); 757 pci = WinSendDlgItemMsg(hwnd, DSZ_CNR, CM_QUERYRECORD, 758 MPFROMP(pci), 759 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER)); 760 } 761 strrev(pszFileName); 762 if (!fVTreeOpensWPS) 763 OpenDirCnr((HWND) 0, 764 (hwndMain) ? hwndMain : HWND_DESKTOP, 765 hwnd, FALSE, pszFileName); 766 else { 767 768 ULONG size = sizeof(ULONG); 769 ULONG flWindowAttr = CV_ICON; 770 CHAR s[33]; 771 772 strcpy(s, "ICON"); 773 PrfQueryProfileData(fmprof, appname, "DirflWindowAttr", 774 (PVOID) & flWindowAttr, &size); 775 if (flWindowAttr & CV_DETAIL) { 776 if (IsRoot(pszFileName)) 777 strcpy(s, "TREE"); 778 else 779 strcpy(s, "DETAILS"); 820 780 } 781 OpenObject(pszFileName, s, hwnd); 821 782 } 822 break; 823 case CN_EMPHASIS: 824 pState = INSTDATA(hwnd); 825 if(pState && !pState->working && mp2) { 826 827 PNOTIFYRECORDEMPHASIS pre = mp2; 828 829 pci = (PCNRITEM)((pre) ? pre->pRecord : NULL); 830 if(pci && (pre->fEmphasisMask & CRA_SELECTED) && 831 (pci->rc.flRecordAttr & CRA_SELECTED)) { 832 commafmt(szBytes,sizeof(szBytes),pci->attrFile); 833 sprintf(sz, 834 "%s %s%s", 835 szBytes, 836 GetPString(IDS_FILETEXT), 837 &"s"[pci->attrFile == 1]); 838 WinSetDlgItemText(hwnd, 839 DSZ_NUMFILES, 840 sz); 841 } 783 } 784 } 785 break; 786 case CN_EMPHASIS: 787 pState = INSTDATA(hwnd); 788 if (pState && !pState->working && mp2) { 789 790 PNOTIFYRECORDEMPHASIS pre = mp2; 791 792 pci = (PCNRITEM) ((pre) ? pre->pRecord : NULL); 793 if (pci && (pre->fEmphasisMask & CRA_SELECTED) && 794 (pci->rc.flRecordAttr & CRA_SELECTED)) { 795 commafmt(szBytes, sizeof(szBytes), pci->attrFile); 796 sprintf(sz, 797 "%s %s%s", 798 szBytes, 799 GetPString(IDS_FILETEXT), &"s"[pci->attrFile == 1]); 800 WinSetDlgItemText(hwnd, DSZ_NUMFILES, sz); 801 } 802 } 803 break; 804 } 805 return 0; 806 807 case WM_COMMAND: 808 switch (SHORT1FROMMP(mp1)) { 809 case IDM_HELP: 810 if (hwndHelp) 811 WinSendMsg(hwndHelp, HM_DISPLAY_HELP, 812 MPFROM2SHORT(HELP_DIRSIZE, 0), MPFROMSHORT(HM_RESOURCEID)); 813 break; 814 815 case DSZ_PRINT: 816 // Save button 817 pState = INSTDATA(hwnd); 818 if (!pState) 819 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); 820 else { 821 822 CHAR pszFileName[CCHMAXPATH]; 823 FILE *fp; 824 825 save_dir2(pszFileName); 826 sprintf(&pszFileName[strlen(pszFileName)], "\\%csizes.Rpt", 827 (pState) ? toupper(*pState->szDirName) : '+'); 828 if (export_filename(hwnd, pszFileName, FALSE) && *pszFileName) { 829 if (stricmp(pszFileName, "PRN") && 830 strnicmp(pszFileName, "\\DEV\\LPT", 8) && 831 !strchr(pszFileName, '.')) 832 strcat(pszFileName, ".RPT"); 833 fp = fopen(pszFileName, "a+"); 834 if (!fp) { 835 saymsg(MB_CANCEL, 836 hwnd, 837 GetPString(IDS_ERRORTEXT), 838 GetPString(IDS_COMPCANTOPENTEXT), pszFileName); 842 839 } 843 break;844 }845 return 0;846 847 case WM_COMMAND:848 switch(SHORT1FROMMP(mp1)) {849 case IDM_HELP:850 if(hwndHelp)851 WinSendMsg(hwndHelp,HM_DISPLAY_HELP,852 MPFROM2SHORT(HELP_DIRSIZE,0),853 MPFROMSHORT(HM_RESOURCEID));854 break;855 856 case DSZ_PRINT:857 // Save button858 pState = INSTDATA(hwnd);859 if (!pState)860 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);861 840 else { 862 863 CHAR pszFileName[CCHMAXPATH]; 864 FILE *fp; 865 866 save_dir2(pszFileName); 867 sprintf(&pszFileName[strlen(pszFileName)],"\\%csizes.Rpt", 868 (pState) ? toupper(*pState->szDirName) : '+'); 869 if (export_filename(hwnd,pszFileName,FALSE) && *pszFileName) { 870 if (stricmp(pszFileName,"PRN") && 871 strnicmp(pszFileName,"\\DEV\\LPT",8) && 872 !strchr(pszFileName,'.')) 873 strcat(pszFileName,".RPT"); 874 fp = fopen(pszFileName,"a+"); 875 if (!fp) { 876 saymsg(MB_CANCEL, 877 hwnd, 878 GetPString(IDS_ERRORTEXT), 879 GetPString(IDS_COMPCANTOPENTEXT), 880 pszFileName); 881 } 882 else { 883 WinSetPointer(HWND_DESKTOP,hptrBusy); 884 PrintToFile(WinWindowFromID(hwnd,DSZ_CNR),0,NULL,fp); 885 fclose(fp); 886 WinSetPointer(HWND_DESKTOP,hptrArrow); 887 } 888 } 841 WinSetPointer(HWND_DESKTOP, hptrBusy); 842 PrintToFile(WinWindowFromID(hwnd, DSZ_CNR), 0, NULL, fp); 843 fclose(fp); 844 WinSetPointer(HWND_DESKTOP, hptrArrow); 889 845 } 890 break; 891 892 case DSZ_EXPAND: 893 case DSZ_COLLAPSE: 894 pState = INSTDATA(hwnd); 895 if (pState) { 896 pci = (PCNRITEM)WinSendDlgItemMsg(hwnd,DSZ_CNR, 897 CM_QUERYRECORDEMPHASIS, 898 MPFROMLONG(CMA_FIRST), 899 MPFROMSHORT(CRA_CURSORED)); 900 if(pci) 901 { 902 WinEnableWindow(WinWindowFromID(hwnd,DID_OK),FALSE); 903 WinEnableWindow(WinWindowFromID(hwnd,IDM_HELP),FALSE); 904 WinEnableWindow(WinWindowFromID(hwnd,DSZ_COLLAPSE),FALSE); 905 WinEnableWindow(WinWindowFromID(hwnd,DSZ_EXPAND),FALSE); 906 WinEnableWindow(WinWindowFromID(hwnd,DSZ_PRINT),FALSE); 907 WinEnableWindow(WinWindowFromID(hwnd,DID_CANCEL),FALSE); 908 // fixme to use thread - too slow on large trees 909 ExpandAll(WinWindowFromID(hwnd,DSZ_CNR), 910 (SHORT1FROMMP(mp1) == DSZ_EXPAND),pci); 911 WinEnableWindow(WinWindowFromID(hwnd,DID_OK),TRUE); 912 WinEnableWindow(WinWindowFromID(hwnd,IDM_HELP),TRUE); 913 WinEnableWindow(WinWindowFromID(hwnd,DSZ_COLLAPSE),TRUE); 914 WinEnableWindow(WinWindowFromID(hwnd,DSZ_EXPAND),TRUE); 915 WinEnableWindow(WinWindowFromID(hwnd,DSZ_PRINT),TRUE); 916 WinEnableWindow(WinWindowFromID(hwnd,DID_CANCEL),TRUE); 917 } 918 } 919 break; 920 921 case DID_OK: 922 case DID_CANCEL: 923 pState = INSTDATA(hwnd); 924 if (!pState) 925 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); 926 else { 927 if (pState->working) { 928 pState->dying = TRUE; 929 pState->chStopFlag = 0xff; 930 DosBeep(1000,100); // Complain? 931 } 932 else 933 WinDismissDlg(hwnd,0); 934 } 935 break; 936 } // switch mp1 937 return 0; 938 939 case WM_CLOSE: 940 pState = INSTDATA(hwnd); 941 if(pState) 942 pState->chStopFlag = 0xff; 943 DosSleep(1L); 846 } 847 } 944 848 break; 945 849 946 case WM_DESTROY: 850 case DSZ_EXPAND: 851 case DSZ_COLLAPSE: 947 852 pState = INSTDATA(hwnd); 948 853 if (pState) { 949 pState->chStopFlag = 0xff; 950 if (pState->hptr) 951 WinDestroyPointer(pState->hptr); 952 DosSleep(33L); 953 free (pState); // Let's hope no one is still looking 954 } 955 DosPostEventSem(CompactSem); 854 pci = (PCNRITEM) WinSendDlgItemMsg(hwnd, DSZ_CNR, 855 CM_QUERYRECORDEMPHASIS, 856 MPFROMLONG(CMA_FIRST), 857 MPFROMSHORT(CRA_CURSORED)); 858 if (pci) { 859 WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE); 860 WinEnableWindow(WinWindowFromID(hwnd, IDM_HELP), FALSE); 861 WinEnableWindow(WinWindowFromID(hwnd, DSZ_COLLAPSE), FALSE); 862 WinEnableWindow(WinWindowFromID(hwnd, DSZ_EXPAND), FALSE); 863 WinEnableWindow(WinWindowFromID(hwnd, DSZ_PRINT), FALSE); 864 WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), FALSE); 865 // fixme to use thread - too slow on large trees 866 ExpandAll(WinWindowFromID(hwnd, DSZ_CNR), 867 (SHORT1FROMMP(mp1) == DSZ_EXPAND), pci); 868 WinEnableWindow(WinWindowFromID(hwnd, DID_OK), TRUE); 869 WinEnableWindow(WinWindowFromID(hwnd, IDM_HELP), TRUE); 870 WinEnableWindow(WinWindowFromID(hwnd, DSZ_COLLAPSE), TRUE); 871 WinEnableWindow(WinWindowFromID(hwnd, DSZ_EXPAND), TRUE); 872 WinEnableWindow(WinWindowFromID(hwnd, DSZ_PRINT), TRUE); 873 WinEnableWindow(WinWindowFromID(hwnd, DID_CANCEL), TRUE); 874 } 875 } 956 876 break; 957 } 958 return WinDefDlgProc(hwnd,msg,mp1,mp2); 877 878 case DID_OK: 879 case DID_CANCEL: 880 pState = INSTDATA(hwnd); 881 if (!pState) 882 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); 883 else { 884 if (pState->working) { 885 pState->dying = TRUE; 886 pState->chStopFlag = 0xff; 887 DosBeep(1000, 100); // Complain? 888 } 889 else 890 WinDismissDlg(hwnd, 0); 891 } 892 break; 893 } // switch mp1 894 return 0; 895 896 case WM_CLOSE: 897 pState = INSTDATA(hwnd); 898 if (pState) 899 pState->chStopFlag = 0xff; 900 DosSleep(1L); 901 break; 902 903 case WM_DESTROY: 904 pState = INSTDATA(hwnd); 905 if (pState) { 906 pState->chStopFlag = 0xff; 907 if (pState->hptr) 908 WinDestroyPointer(pState->hptr); 909 DosSleep(33L); 910 free(pState); // Let's hope no one is still looking 911 } 912 DosPostEventSem(CompactSem); 913 break; 914 } 915 return WinDefDlgProc(hwnd, msg, mp1, mp2); 959 916 }
Note:
See TracChangeset
for help on using the changeset viewer.