- Timestamp:
 - May 26, 2005, 4:43:34 AM (20 years ago)
 - File:
 - 
      
- 1 edited
 
- 
          
  trunk/dll/filldir.c (modified) (80 diffs)
 
 
Legend:
- Unmodified
 - Added
 - Removed
 
- 
      
trunk/dll/filldir.c
r145 r167 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2001, 2005 Steven H. Levine9 Copyright (c) 2001, 2005 Steven H. Levine 10 10 11 11 12 Sep 02 SHL Rework symbols to understand code … … 14 14 10 Jan 04 SHL ProcessDirectory: avoid most large drive failures 15 15 24 May 05 SHL Rework Win_Error usage 16 24 May 05 SHL Rework for CNRITEM.szSubject 17 25 May 05 SHL Rework for ULONGLONG 18 25 May 05 SHL Rework FillInRecordFromFFB 19 25 May 05 SHL Rework FillTreeCnr 16 20 17 21 ***********************************************************************/ … … 19 23 #define INCL_DOS 20 24 #define INCL_WIN 21 25 #define INCL_LONGLONG 22 26 #include <os2.h> 27 23 28 #include <stdarg.h> 24 29 #include <stdio.h> … … 27 32 #include <ctype.h> 28 33 #include <time.h> 34 29 35 #include "fm3dll.h" 30 36 #include "fm3str.h" … … 34 40 35 41 36 HPOINTER IDFile(ULONG cmp)42 static HPOINTER IDFile(ULONG cmp) 37 43 { 38 44 HPOINTER hptr; 39 45 40 46 hptr = (HPOINTER)0; 41 if (cmp == *(ULONG *)".EXE" || cmp == *(ULONG *)".CMD" ||42 cmp == *(ULONG *)".BAT" || cmp == *(ULONG *)".COM")47 if (cmp == *(ULONG *)".EXE" || cmp == *(ULONG *)".CMD" || 48 cmp == *(ULONG *)".BAT" || cmp == *(ULONG *)".COM") 43 49 hptr = hptrApp; 44 else if (cmp == *(ULONG *)".ZIP" || cmp == *(ULONG *)".LZH" ||45 cmp == *(ULONG *)".ARJ" || cmp == *(ULONG *)".ARC" ||46 cmp == *(ULONG *)".ZOO" || cmp == *(ULONG *)".RAR")50 else if (cmp == *(ULONG *)".ZIP" || cmp == *(ULONG *)".LZH" || 51 cmp == *(ULONG *)".ARJ" || cmp == *(ULONG *)".ARC" || 52 cmp == *(ULONG *)".ZOO" || cmp == *(ULONG *)".RAR") 47 53 hptr = hptrArc; 48 else if (cmp == *(ULONG *)".BMP" || cmp == *(ULONG *)".ICO" ||49 cmp == *(ULONG *)".PTR" || cmp == *(ULONG *)".GIF" ||50 cmp == *(ULONG *)".TIF" || cmp == *(ULONG *)".PCX" ||51 cmp == *(ULONG *)".TGA" || cmp == *(ULONG *)".XBM")54 else if (cmp == *(ULONG *)".BMP" || cmp == *(ULONG *)".ICO" || 55 cmp == *(ULONG *)".PTR" || cmp == *(ULONG *)".GIF" || 56 cmp == *(ULONG *)".TIF" || cmp == *(ULONG *)".PCX" || 57 cmp == *(ULONG *)".TGA" || cmp == *(ULONG *)".XBM") 52 58 hptr = hptrArt; 53 59 return hptr; … … 55 61 56 62 57 ULONG FillInRecordFromFFB(HWND hwndCnr,PCNRITEM pci, const PSZ pszDirectory,58 const PFILEFINDBUF4 pffb,const BOOL partial,59 DIRCNRDATA *dcd)63 ULONGLONG FillInRecordFromFFB(HWND hwndCnr,PCNRITEM pci, const PSZ pszDirectory, 64 const PFILEFINDBUF4 pffb,const BOOL partial, 65 DIRCNRDATA *dcd) 60 66 { 61 62 67 /* fill in a container record from a FILEFINDBUF4 structure */ 63 68 64 CHAR attrstring[] = "RHS\0DA",cmps[] = ".xxx"; 65 register CHAR *p; 66 HPOINTER hptr; 67 register INT x,y; 68 INT t; 69 ULONG cmp; 69 CHAR attrstring[] = "RHS\0DA"; 70 CHAR cmps[] = ".xxx"; 71 CHAR *p; 72 HPOINTER hptr; 73 UINT x; 74 UINT y; 75 UINT t; 76 ULONG cmp; 77 BOOL rc; 70 78 71 79 pci->hwndCnr = hwndCnr; … … 74 82 /* note! we cheat below, and accept the full pathname in pszDirectory 75 83 if !*pffb->achName. speeds up and simplifies processing elsewhere 76 (like in update.c) */ 77 if(*pffb->achName) { 84 (like in update.c) 85 */ 86 if (*pffb->achName) 87 { 78 88 p = pci->szFileName + (t - 1); 79 if (*p != '\\') {89 if (*p != '\\') { 80 90 p++; 81 91 *p = '\\'; … … 85 95 } 86 96 /* load the object's Subject, if required */ 87 if (pffb->cbList > 4L &&88 dcd && fLoadSubject &&89 (isalpha(*pci->szFileName) &&90 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADSUBJS))) {91 97 if (pffb->cbList > 4L && 98 dcd && fLoadSubject && 99 (isalpha(*pci->szFileName) && 100 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADSUBJS))) 101 { 92 102 APIRET rc; 93 103 EAOP2 eaop; … … 99 109 100 110 pgealist = malloc(sizeof(GEA2LIST) + 32); 101 if(pgealist) { 111 if (pgealist) 112 { 102 113 memset(pgealist,0,sizeof(GEA2LIST) + 32); 103 114 pgea = &pgealist->list[0]; … … 107 118 pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName); 108 119 pfealist = malloc(1532); 109 if(pfealist) { 120 if (pfealist) 121 { 110 122 memset(pfealist,0,1532); 111 123 pfealist->cbList = 1024; … … 115 127 rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST, 116 128 (PVOID)&eaop,(ULONG)sizeof(EAOP2)); 117 if (!rc) {129 if (!rc) { 118 130 pfea = &eaop.fpFEA2List->list[0]; 119 131 value = pfea->szName + pfea->cbName + 1; 120 132 value[pfea->cbValue] = 0; 121 if (*(USHORT *)value == EAT_ASCII)122 strncpy(pci->s ubject,value + (sizeof(USHORT) * 2),39);123 pci->s ubject[39] = 0;133 if (*(USHORT *)value == EAT_ASCII) 134 strncpy(pci->szSubject,value + (sizeof(USHORT) * 2),39); 135 pci->szSubject[39] = 0; 124 136 } 125 137 free(pfealist); … … 128 140 } 129 141 } 130 pci->pszSubject = pci->s ubject;142 pci->pszSubject = pci->szSubject; 131 143 /* load the object's longname */ 132 *pci-> Longname = 0;133 if (pffb->cbList > 4L &&134 dcd && fLoadLongnames &&135 (isalpha(*pci->szFileName) &&136 (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLONGNAMES) &&137 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADLONGS))) {138 144 *pci->szLongname = 0; 145 if (pffb->cbList > 4L && 146 dcd && fLoadLongnames && 147 (isalpha(*pci->szFileName) && 148 (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLONGNAMES) && 149 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADLONGS))) 150 { 139 151 APIRET rc; 140 152 EAOP2 eaop; … … 146 158 147 159 pgealist = malloc(sizeof(GEA2LIST) + 32); 148 if(pgealist) { 160 if (pgealist) 161 { 149 162 memset(pgealist,0,sizeof(GEA2LIST) + 32); 150 163 pgea = &pgealist->list[0]; … … 154 167 pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName); 155 168 pfealist = malloc(1532); 156 if (pfealist) {169 if (pfealist) { 157 170 memset(pfealist,0,1532); 158 171 pfealist->cbList = 1024; … … 162 175 rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST, 163 176 (PVOID)&eaop,(ULONG)sizeof(EAOP2)); 164 if(!rc) { 177 if (!rc) 178 { 165 179 pfea = &eaop.fpFEA2List->list[0]; 166 180 value = pfea->szName + pfea->cbName + 1; 167 181 value[pfea->cbValue] = 0; 168 if (*(USHORT *)value == EAT_ASCII)169 strncpy(pci-> Longname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP);170 pci-> Longname[CCHMAXPATHCOMP - 1] = 0;182 if (*(USHORT *)value == EAT_ASCII) 183 strncpy(pci->szLongname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP); 184 pci->szLongname[CCHMAXPATHCOMP - 1] = 0; 171 185 } 172 186 free(pfealist); … … 175 189 } 176 190 } 177 pci->pszLongname = pci-> Longname;191 pci->pszLongname = pci->szLongname; 178 192 179 193 /* do anything required to case of filename */ 180 if (fForceUpper)194 if (fForceUpper) 181 195 strupr(pci->szFileName); 182 else if (fForceLower)196 else if (fForceLower) 183 197 strlwr(pci->szFileName); 184 198 185 199 /* get an icon to use with it */ 186 if(pffb->attrFile & FILE_DIRECTORY) { 187 if(!fNoIconsDirs && (!isalpha(*pci->szFileName) || 188 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS))) 200 if (pffb->attrFile & FILE_DIRECTORY) 201 { 202 if (!fNoIconsDirs && (!isalpha(*pci->szFileName) || 203 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS))) 189 204 hptr = WinLoadFileIcon(pci->szFileName, FALSE); 190 205 else 191 206 hptr = (HPOINTER)0; 192 207 } 193 else { 208 else 209 { 194 210 if (!fNoIconsFiles && (!isalpha(*pci->szFileName) || 195 211 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS))) 212 { 196 213 hptr = WinLoadFileIcon(pci->szFileName, FALSE); 214 } 197 215 else 198 216 hptr = (HPOINTER)0; 199 if (!hptr || hptr == WinQuerySysPointer(HWND_DESKTOP,SPTR_FILE,FALSE)) { 217 218 if (!hptr || hptr == WinQuerySysPointer(HWND_DESKTOP,SPTR_FILE,FALSE)) 219 { 200 220 p = strrchr(pci->szFileName,'.'); 201 if(p && !p[4]) { 221 if (p && !p[4]) 222 { 202 223 cmps[1] = toupper(p[1]); 203 224 cmps[2] = toupper(p[2]); … … 210 231 } 211 232 } 212 if(!hptr) 233 if (!hptr) 234 { 213 235 hptr = ((pffb->attrFile & FILE_DIRECTORY) != 0) ? hptrDir : 214 236 ((pffb->attrFile & FILE_SYSTEM) != 0) ? hptrSystem : … … 216 238 ((pffb->attrFile & FILE_READONLY) != 0) ? hptrReadonly : 217 239 hptrFile; 240 } 218 241 219 242 /* decide where to point for the container's title text */ 220 if(partial) { 243 if (partial) 244 { 221 245 p = strrchr(pci->szFileName,'\\'); 222 if(!p) { 246 if (!p) 247 { 223 248 p = strrchr(pci->szFileName,':'); 224 if (!p)249 if (!p) 225 250 p = pci->szFileName; 226 251 else 227 252 p++; 228 253 } 229 else if((dcd && dcd->type == TREE_FRAME) || 230 (!(pffb->attrFile & FILE_DIRECTORY) || !*(p + 1))) 254 else if ((dcd && dcd->type == TREE_FRAME) || 255 (!(pffb->attrFile & FILE_DIRECTORY) || !*(p + 1))) 256 { 231 257 p++; 232 if(!*p) 258 } 259 if (!*p) 233 260 p = pci->szFileName; 234 261 } … … 260 287 /* build attribute string for display */ 261 288 y = 0; 262 for(x = 0;x < 6;x++) 263 if(attrstring[x]) 264 pci->szDispAttr[y++] = (CHAR)((pci->attrFile & (1 << x)) ? 265 attrstring[x] : '-'); 289 for (x = 0; x < 6; x++) 290 { 291 if (attrstring[x]) 292 { 293 pci->szDispAttr[y++] = 294 (CHAR)((pci->attrFile & (1 << x)) ? attrstring[x] : '-'); 295 } 296 } 266 297 pci->szDispAttr[5] = 0; 267 298 pci->pszDispAttr = pci->szDispAttr; … … 270 301 271 302 /* check to see if record should be visible */ 272 if(dcd && (*dcd->mask.szMask || dcd->mask.antiattr || 273 ((dcd->mask.attrFile & 274 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) != 275 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)))) { 276 if(*dcd->mask.szMask || dcd->mask.antiattr) { 303 if (dcd && (*dcd->mask.szMask || dcd->mask.antiattr || 304 ((dcd->mask.attrFile & 305 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) != 306 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)))) 307 { 308 if (*dcd->mask.szMask || dcd->mask.antiattr) 309 { 277 310 if(!Filter((PMINIRECORDCORE)pci,(PVOID)&dcd->mask)) 278 311 pci->rc.flRecordAttr |= CRA_FILTERED; … … 286 319 (!(dcd->mask.attrFile & FILE_ARCHIVED) && 287 320 (pci->attrFile & FILE_ARCHIVED))) 321 { 288 322 pci->rc.flRecordAttr |= CRA_FILTERED; 323 } 289 324 } 290 325 291 326 return pffb->cbFile + pci->easize; 292 } 293 294 295 ULONG FillInRecordFromFSA (HWND hwndCnr,PCNRITEM pci,const PSZ pszFileName, 296 const PFILESTATUS4 pfsa4, 297 const BOOL partial, 298 DIRCNRDATA *dcd) 327 328 } // FillInRecordFromFFB 329 330 331 ULONGLONG FillInRecordFromFSA(HWND hwndCnr, 332 PCNRITEM pci, 333 const PSZ pszFileName, 334 const PFILESTATUS4 pfsa4, 335 const BOOL partial, 336 DIRCNRDATA *dcd) // Optional 299 337 { 300 301 338 HPOINTER hptr; 302 CHAR attrstring[] = "RHS\0DA",cmps[] = ".xxx"; 339 CHAR attrstring[] = "RHS\0DA"; 340 CHAR cmps[] = ".xxx"; 303 341 register CHAR *p; 304 register INT x,y; 342 register INT x; 343 register INT y; 305 344 ULONG cmp; 306 345 … … 310 349 strcpy(pci->szFileName,pszFileName); 311 350 /* load the object's Subject, if required */ 312 if(pfsa4->cbList > 4L && 313 dcd && fLoadSubject && 314 (!isalpha(*pci->szFileName) || 315 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADSUBJS))) { 316 351 if (pfsa4->cbList > 4L && 352 dcd && 353 fLoadSubject && 354 (!isalpha(*pci->szFileName) || 355 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADSUBJS))) 356 { 317 357 APIRET rc; 318 358 EAOP2 eaop; … … 324 364 325 365 pgealist = malloc(sizeof(GEA2LIST) + 32); 326 if (pgealist) {366 if (pgealist) { 327 367 memset(pgealist,0,sizeof(GEA2LIST) + 32); 328 368 pgea = &pgealist->list[0]; … … 332 372 pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName); 333 373 pfealist = malloc(1532); 334 if (pfealist) {374 if (pfealist) { 335 375 memset(pfealist,0,1532); 336 376 pfealist->cbList = 1024; … … 341 381 (PVOID)&eaop, 342 382 (ULONG)sizeof(EAOP2)); 343 if (!rc) {383 if (!rc) { 344 384 pfea = &eaop.fpFEA2List->list[0]; 345 385 value = pfea->szName + pfea->cbName + 1; 346 386 value[pfea->cbValue] = 0; 347 if (*(USHORT *)value == EAT_ASCII)348 strncpy(pci->s ubject,value + (sizeof(USHORT) * 2),39);349 pci->s ubject[39] = 0;387 if (*(USHORT *)value == EAT_ASCII) 388 strncpy(pci->szSubject,value + (sizeof(USHORT) * 2),39); 389 pci->szSubject[39] = 0; 350 390 } 351 391 free(pfealist); … … 354 394 } 355 395 } 356 pci->pszSubject = pci->subject; 357 *pci->Longname = 0; 358 if(pfsa4->cbList > 4L && 359 dcd && fLoadLongnames && 360 (!isalpha(*pci->szFileName) || 361 ((driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLONGNAMES) && 362 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADLONGS)))) 396 pci->pszSubject = pci->szSubject; 397 *pci->szLongname = 0; 398 if (pfsa4->cbList > 4L && 399 dcd && 400 fLoadLongnames && 401 (!isalpha(*pci->szFileName) || 402 ((driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLONGNAMES) && 403 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADLONGS)))) 363 404 { 364 405 APIRET rc; … … 371 412 372 413 pgealist = malloc(sizeof(GEA2LIST) + 32); 373 if (pgealist) {414 if (pgealist) { 374 415 memset(pgealist,0,sizeof(GEA2LIST) + 32); 375 416 pgea = &pgealist->list[0]; … … 379 420 pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName); 380 421 pfealist = malloc(1532); 381 if (pfealist) {422 if (pfealist) { 382 423 memset(pfealist,0,1532); 383 424 pfealist->cbList = 1024; … … 387 428 rc = DosQueryPathInfo(pci->szFileName,FIL_QUERYEASFROMLIST, 388 429 (PVOID)&eaop,(ULONG)sizeof(EAOP2)); 389 if (!rc) {430 if (!rc) { 390 431 pfea = &eaop.fpFEA2List->list[0]; 391 432 value = pfea->szName + pfea->cbName + 1; 392 433 value[pfea->cbValue] = 0; 393 if (*(USHORT *)value == EAT_ASCII)394 strncpy(pci-> Longname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP);395 pci-> Longname[CCHMAXPATHCOMP - 1] = 0;434 if (*(USHORT *)value == EAT_ASCII) 435 strncpy(pci->szLongname,value + (sizeof(USHORT) * 2),CCHMAXPATHCOMP); 436 pci->szLongname[CCHMAXPATHCOMP - 1] = 0; 396 437 } 397 438 free(pfealist); … … 400 441 } 401 442 } 402 pci->pszLongname = pci-> Longname;403 if (fForceUpper)443 pci->pszLongname = pci->szLongname; 444 if (fForceUpper) 404 445 strupr(pci->szFileName); 405 else if (fForceLower)446 else if (fForceLower) 406 447 strlwr(pci->szFileName); 407 448 408 if (pfsa4->attrFile & FILE_DIRECTORY) {409 if (!fNoIconsDirs && (!isalpha(*pci->szFileName) ||410 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS)))449 if (pfsa4->attrFile & FILE_DIRECTORY) { 450 if (!fNoIconsDirs && (!isalpha(*pci->szFileName) || 451 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS))) 411 452 hptr = WinLoadFileIcon(pci->szFileName, FALSE); 412 453 else 413 454 hptr = (HPOINTER)0; 414 455 } 415 else { 416 if(!fNoIconsFiles && (!isalpha(*pci->szFileName) || 417 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS))) 456 else 457 { 458 if (!fNoIconsFiles && (!isalpha(*pci->szFileName) || 459 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOLOADICONS))) 418 460 hptr = WinLoadFileIcon(pci->szFileName, FALSE); 419 else { 461 else 462 { 420 463 p = strrchr(pci->szFileName,'.'); 421 if (p && !p[4]) {464 if (p && !p[4]) { 422 465 cmps[1] = toupper(p[1]); 423 466 cmps[2] = toupper(p[2]); … … 430 473 } 431 474 } 432 if (!hptr)475 if (!hptr) 433 476 hptr = ((pfsa4->attrFile & FILE_DIRECTORY) != 0) ? hptrDir : 434 477 ((pfsa4->attrFile & FILE_SYSTEM) != 0) ? hptrSystem : … … 437 480 hptrFile; 438 481 439 if (partial) {482 if (partial) { 440 483 p = strrchr(pci->szFileName,'\\'); 441 if (!p) {484 if (!p) { 442 485 p = strrchr(pci->szFileName,':'); 443 if (!p)486 if (!p) 444 487 p = pci->szFileName; 445 488 else 446 489 p++; 447 490 } 448 else if((dcd && dcd->type == TREE_FRAME) || 449 (!(pfsa4->attrFile & FILE_DIRECTORY) || !*(p + 1))) 491 else if ((dcd && dcd->type == TREE_FRAME) || 492 !(pfsa4->attrFile & FILE_DIRECTORY) || 493 !*(p + 1)) 450 494 p++; 451 if (!*p)495 if (!*p) 452 496 p = pci->szFileName; 453 497 } … … 478 522 y = 0; 479 523 for(x = 0;x < 6;x++) 480 if (attrstring[x])524 if (attrstring[x]) 481 525 pci->szDispAttr[y++] = (CHAR)((pci->attrFile & (1 << x)) ? 482 526 attrstring[x] : '-'); … … 486 530 pci->rc.hptrIcon = hptr; 487 531 488 if(dcd && (*dcd->mask.szMask || dcd->mask.antiattr || 489 ((dcd->mask.attrFile & 490 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) != 491 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)))) { 492 if(*dcd->mask.szMask || dcd->mask.antiattr) { 493 if(!Filter((PMINIRECORDCORE)pci,(PVOID)&dcd->mask)) 532 if (dcd && 533 (*dcd->mask.szMask || dcd->mask.antiattr || 534 ((dcd->mask.attrFile & 535 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) != 536 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)))) 537 { 538 if (*dcd->mask.szMask || dcd->mask.antiattr) 539 { 540 if (!Filter((PMINIRECORDCORE)pci,(PVOID)&dcd->mask)) 494 541 pci->rc.flRecordAttr |= CRA_FILTERED; 495 542 } 496 else if ((!(dcd->mask.attrFile & FILE_HIDDEN) &&497 (pci->attrFile & FILE_HIDDEN)) ||498 (!(dcd->mask.attrFile & FILE_SYSTEM) &&499 (pci->attrFile & FILE_SYSTEM)) ||500 (!(dcd->mask.attrFile & FILE_READONLY) &&501 (pci->attrFile & FILE_READONLY)) ||502 (!(dcd->mask.attrFile & FILE_ARCHIVED) &&503 (pci->attrFile & FILE_ARCHIVED)))543 else if ((!(dcd->mask.attrFile & FILE_HIDDEN) && 544 (pci->attrFile & FILE_HIDDEN)) || 545 (!(dcd->mask.attrFile & FILE_SYSTEM) && 546 (pci->attrFile & FILE_SYSTEM)) || 547 (!(dcd->mask.attrFile & FILE_READONLY) && 548 (pci->attrFile & FILE_READONLY)) || 549 (!(dcd->mask.attrFile & FILE_ARCHIVED) && 550 (pci->attrFile & FILE_ARCHIVED))) 504 551 pci->rc.flRecordAttr |= CRA_FILTERED; 505 552 } 506 553 507 554 return pfsa4->cbFile + pci->easize; 508 } 509 510 511 ULONG ProcessDirectory (const HWND hwndCnr, const PCNRITEM pciParent, 512 const CHAR *szDirBase, const BOOL filestoo, 513 const BOOL recurse,const BOOL partial, 514 CHAR *stopflag,DIRCNRDATA *dcd,ULONG *foundany) 555 556 } // FillInRecordFromFSA 557 558 559 VOID ProcessDirectory(const HWND hwndCnr, const PCNRITEM pciParent, 560 const CHAR *szDirBase, const BOOL filestoo, 561 const BOOL recurse,const BOOL partial, 562 CHAR *stopflag, 563 DIRCNRDATA *dcd, // Optional 564 ULONG *pulTotalFiles, // Optional 565 PULONGLONG pullTotalBytes) // Optional 515 566 { 516 517 567 /* put all the directories (and files if filestoo is TRUE) from a 518 568 * directory into the container. recurse through subdirectories if … … 522 572 PSZ pszFileSpec; 523 573 INT t; 524 PFILEFINDBUF4 paffbFound,*papffbSelected,pffbFile,paffbTotal = NULL,paffbTemp; 574 PFILEFINDBUF4 paffbFound; 575 PFILEFINDBUF4 *papffbSelected; 576 PFILEFINDBUF4 pffbFile; 577 PFILEFINDBUF4 paffbTotal = NULL; 578 PFILEFINDBUF4 paffbTemp; 525 579 HDIR hdir = HDIR_CREATE; 526 ULONG ulMaxFiles,ulExtraBytes,ulM = 1,ulTotal = 0L; 527 ULONG numbytes,totalbytes,returnbytes = 0L; 580 ULONG ulFileCnt; 581 ULONG ulExtraBytes; 582 ULONG ulM = 1; 583 ULONG ulTotal = 0L; 584 ULONGLONG ullBytes; 585 ULONGLONG ullTotalBytes; 586 ULONG ulReturnFiles = 0; 587 ULONGLONG ullReturnBytes = 0; 528 588 PCH pchEndPath; 529 589 APIRET rc; 530 PCNRITEM pci,pciFirst,pcit; 590 PCNRITEM pci; 591 PCNRITEM pciFirst; 592 PCNRITEM pcit; 531 593 RECORDINSERT ri; 532 register PBYTE pByte,pByte2; 533 534 if(foundany) 535 (*foundany) = 0L; 536 if(isalpha(*szDirBase) && szDirBase[1] == ':' && szDirBase[2] == '\\') { 537 // if(!(driveflags[toupper(*szDirBase) - 'A'] & DRIVE_NOLONGNAMES)) 594 PBYTE pByte; 595 PBYTE pByte2; 596 BOOL ok = TRUE; 597 598 if (isalpha(*szDirBase) && szDirBase[1] == ':' && szDirBase[2] == '\\') 599 { 600 // if (!(driveflags[toupper(*szDirBase) - 'A'] & DRIVE_NOLONGNAMES)) 538 601 ulExtraBytes = EXTRA_RECORD_BYTES; 539 //else540 //ulExtraBytes = EXTRA_RECORD_BYTES2;541 if ((driveflags[toupper(*szDirBase) - 'A'] & DRIVE_REMOTE) && fRemoteBug)542 ulM = 1; /* file system gets confused */543 else if (driveflags[toupper(*szDirBase) - 'A'] & DRIVE_ZIPSTREAM)602 // else 603 // ulExtraBytes = EXTRA_RECORD_BYTES2; 604 if ((driveflags[toupper(*szDirBase) - 'A'] & DRIVE_REMOTE) && fRemoteBug) 605 ulM = 1; /* file system gets confused */ 606 else if (driveflags[toupper(*szDirBase) - 'A'] & DRIVE_ZIPSTREAM) 544 607 ulM = min(FilesToGet,225); /* anything more is wasted */ 545 608 else 546 609 ulM = FilesToGet; /* full-out */ 547 610 } 548 else { 611 else 612 { 549 613 ulExtraBytes = EXTRA_RECORD_BYTES; 550 614 ulM = FilesToGet; 551 615 } 552 if (OS2ver[0] == 20 && OS2ver[1] < 30)616 if (OS2ver[0] == 20 && OS2ver[1] < 30) 553 617 ulM = min(ulM,(65535 / sizeof(FILEFINDBUF4))); 554 618 555 ul MaxFiles= ulM;619 ulFileCnt = ulM; 556 620 pszFileSpec = malloc(CCHMAXPATH + 2); 557 621 paffbFound = malloc((ulM + 1) * sizeof(FILEFINDBUF4)); 558 622 papffbSelected = malloc((ulM + 1) * sizeof(PFILEFINDBUF4)); 559 if (paffbFound && papffbSelected && pszFileSpec) {623 if (paffbFound && papffbSelected && pszFileSpec) { 560 624 t = strlen(szDirBase); 561 625 memcpy(pszFileSpec,szDirBase,t + 1); 562 626 pchEndPath = pszFileSpec + t; 563 if (*(pchEndPath - 1) != '\\') {627 if (*(pchEndPath - 1) != '\\') { 564 628 memcpy(pchEndPath,"\\",2); 565 629 pchEndPath++; … … 572 636 FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN, 573 637 paffbFound, ulM * sizeof(FILEFINDBUF4), 574 &ul MaxFiles, FIL_QUERYEASIZE);638 &ulFileCnt, FIL_QUERYEASIZE); 575 639 priority_normal(); 576 640 *pchEndPath = 0; 577 if(!rc) { 578 while(!rc) { 641 if (!rc) 642 { 643 while (!rc) 644 { 579 645 /* 580 646 * remove . and .. from list if present … … 587 653 register ULONG x; 588 654 589 if (stopflag && *stopflag)655 if (stopflag && *stopflag) 590 656 goto Abort; 591 657 pByte = (PBYTE)paffbFound; 592 658 x = 0L; 593 while(x < ulMaxFiles) { 659 while (x < ulFileCnt) 660 { 594 661 pffbFile = (PFILEFINDBUF4)pByte; 595 if(!*pffbFile->achName || 596 (!filestoo && !(pffbFile->attrFile & FILE_DIRECTORY)) || 597 (((pffbFile->attrFile & FILE_DIRECTORY) && 598 pffbFile->achName[0] == '.') && 599 (!pffbFile->achName[1] || (pffbFile->achName[1] == '.' && 600 !pffbFile->achName[2])))) 601 ulMaxFiles--; 662 if (!*pffbFile->achName || 663 (!filestoo && !(pffbFile->attrFile & FILE_DIRECTORY)) || 664 (((pffbFile->attrFile & FILE_DIRECTORY) && 665 pffbFile->achName[0] == '.') && 666 (!pffbFile->achName[1] || (pffbFile->achName[1] == '.' && 667 !pffbFile->achName[2])))) 668 { 669 ulFileCnt--; 670 } 602 671 else 603 672 papffbSelected[x++] = pffbFile; 604 if(!pffbFile->oNextEntryOffset) { 605 ulMaxFiles = x; 673 if (!pffbFile->oNextEntryOffset) 674 { 675 ulFileCnt = x; 606 676 break; 607 677 } 608 678 pByte += pffbFile->oNextEntryOffset; 609 679 } 610 if(ulMaxFiles) { 611 if(stopflag && *stopflag) 680 if (ulFileCnt) 681 { 682 if (stopflag && *stopflag) 612 683 goto Abort; 613 if(fSyncUpdates) { 684 if (fSyncUpdates) 685 { 614 686 pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD, 615 687 MPFROMLONG(ulExtraBytes), 616 MPFROMLONG(ul MaxFiles));617 if (pciFirst) {618 688 MPFROMLONG(ulFileCnt)); 689 if (pciFirst) 690 { 619 691 register INT i; 620 692 621 693 pci = pciFirst; 622 totalbytes = 0L;623 for(i = 0; i < ul MaxFiles; i++) {694 ullTotalBytes = 0; 695 for(i = 0; i < ulFileCnt; i++) { 624 696 pffbFile = papffbSelected[i]; 625 numbytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec, 626 pffbFile,partial,dcd); 627 if(numbytes != -1) { 697 ullBytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec, 698 pffbFile,partial,dcd); 699 if (rc) 700 { 628 701 pci = (PCNRITEM)pci->rc.preccNextRecord; 629 totalbytes += numbytes; 630 if (totalbytes == -1) 631 totalbytes--; // fixme for real someday 632 702 ullTotalBytes += ullBytes; 633 703 } 634 else { 704 else 705 { 635 706 Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__, 636 707 GetPString(IDS_FILLDIRERR1TEXT), 637 708 hwndCnr); 638 ul MaxFiles--;709 ulFileCnt--; 639 710 } 640 711 } 641 if(ulMaxFiles) { 712 if (ulFileCnt) 713 { 642 714 memset(&ri,0,sizeof(RECORDINSERT)); 643 715 ri.cb = sizeof(RECORDINSERT); … … 645 717 ri.pRecordParent = (PRECORDCORE) pciParent; 646 718 ri.zOrder = (ULONG) CMA_TOP; 647 ri.cRecordsInsert = ul MaxFiles;719 ri.cRecordsInsert = ulFileCnt; 648 720 ri.fInvalidateRecord = (!fSyncUpdates && dcd && 649 721 dcd->type == DIR_FRAME) ? 650 722 FALSE : TRUE; 651 if (!WinSendMsg(hwndCnr,652 CM_INSERTRECORD,653 MPFROMP(pciFirst),654 MPFROMP(&ri)))723 if (!WinSendMsg(hwndCnr, 724 CM_INSERTRECORD, 725 MPFROMP(pciFirst), 726 MPFROMP(&ri))) 655 727 { 656 728 DosSleep(100L); 657 729 WinSetFocus(HWND_DESKTOP,hwndCnr); 658 if (!WinSendMsg(hwndCnr,659 CM_INSERTRECORD,660 MPFROMP(pciFirst),661 MPFROMP(&ri))) {730 if (!WinSendMsg(hwndCnr, 731 CM_INSERTRECORD, 732 MPFROMP(pciFirst), 733 MPFROMP(&ri))) { 662 734 663 735 { // SHL … … 674 746 Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__, 675 747 GetPString(IDS_FILLDIRERR2TEXT)); 676 totalbytes = -1; 677 if(WinIsWindow((HAB)0,hwndCnr)) { 748 ok = FALSE; 749 ullTotalBytes = 0; 750 if (WinIsWindow((HAB)0,hwndCnr)) 751 { 678 752 pci = pciFirst; 679 while(pci) { 753 while (pci) 754 { 680 755 pcit = (PCNRITEM)pci->rc.preccNextRecord; 681 756 WinSendMsg(hwndCnr, … … 690 765 } 691 766 } 692 else { 767 else 768 { 693 769 Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__, 694 770 GetPString(IDS_FILLDIRERR3TEXT)); 695 totalbytes = -1; 771 ok = FALSE; 772 ullTotalBytes = 0; 696 773 } 697 if(totalbytes != -1) { 698 returnbytes += totalbytes; 699 if (returnbytes == -1) 700 returnbytes--; // fixme for real someday 701 if(foundany) 702 (*foundany) += ulMaxFiles; 774 if (ok) 775 { 776 ullReturnBytes += ullTotalBytes; 777 ulReturnFiles += ulFileCnt; 703 778 } 704 779 } 705 else { 780 else 781 { 706 782 paffbTemp = realloc(paffbTotal,sizeof(FILEFINDBUF4) * 707 (ulMaxFiles + ulTotal)); 708 if(paffbTemp) { 783 (ulFileCnt + ulTotal)); 784 if (paffbTemp) 785 { 709 786 paffbTotal = paffbTemp; 710 for(x = 0;x < ul MaxFiles;x++)787 for(x = 0;x < ulFileCnt;x++) 711 788 paffbTotal[x + ulTotal] = *papffbSelected[x]; 712 ulTotal += ul MaxFiles;789 ulTotal += ulFileCnt; 713 790 } 714 else { 791 else 792 { 715 793 saymsg(MB_ENTER, 716 794 HWND_DESKTOP, … … 722 800 } 723 801 } 724 if (stopflag && *stopflag)802 if (stopflag && *stopflag) 725 803 goto Abort; 726 ul MaxFiles= ulM;804 ulFileCnt = ulM; 727 805 DosError(FERR_DISABLEHARDERR); 728 806 rc = DosFindNext(hdir, paffbFound, ulM * sizeof(FILEFINDBUF4), 729 &ul MaxFiles);807 &ulFileCnt); 730 808 priority_normal(); 731 if (rc)809 if (rc) 732 810 DosError(FERR_DISABLEHARDERR); 733 811 } 734 812 DosFindClose(hdir); 735 813 736 if (paffbFound || papffbSelected) {737 if (paffbFound)814 if (paffbFound || papffbSelected) { 815 if (paffbFound) 738 816 free(paffbFound); 739 if (papffbSelected)817 if (papffbSelected) 740 818 free(papffbSelected); 741 819 papffbSelected = NULL; … … 743 821 } 744 822 745 if(ulTotal && paffbTotal) { 746 if(stopflag && *stopflag) 823 if (ulTotal && paffbTotal) 824 { 825 826 if (stopflag && *stopflag) 747 827 goto Abort; 828 748 829 pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD, 749 830 MPFROMLONG(ulExtraBytes), 750 831 MPFROMLONG(ulTotal)); 751 if (pciFirst) {752 832 if (pciFirst) 833 { 753 834 register INT i; 754 835 755 836 pci = pciFirst; 756 totalbytes = 0L;837 ullTotalBytes = 0; 757 838 pByte2 = (PBYTE)paffbTotal; 758 for(i = 0; i < ulTotal; i++) { 839 for(i = 0; i < ulTotal; i++) 840 { 759 841 pffbFile = (PFILEFINDBUF4)pByte2; 760 numbytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec,842 ullBytes = FillInRecordFromFFB(hwndCnr,pci,pszFileSpec, 761 843 pffbFile,partial,dcd); 762 if (numbytes != -1) { 763 pci = (PCNRITEM)pci->rc.preccNextRecord; 764 totalbytes += numbytes; 765 if (totalbytes == -1) 766 totalbytes--; // fixme for real someday 767 } 768 else { 769 Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__, 770 GetPString(IDS_FILLDIRERR4TEXT), 771 hwndCnr); 772 ulTotal--; 773 } 844 pci = (PCNRITEM)pci->rc.preccNextRecord; 845 ullTotalBytes += ullBytes; 846 774 847 pByte2 += sizeof(FILEFINDBUF4); 775 848 } 776 if(ulTotal) { 849 if (ulTotal) 850 { 777 851 memset(&ri,0,sizeof(RECORDINSERT)); 778 852 ri.cb = sizeof(RECORDINSERT); … … 784 858 dcd->type == DIR_FRAME) ? 785 859 FALSE : TRUE; 786 if(!WinSendMsg(hwndCnr,CM_INSERTRECORD, 787 MPFROMP(pciFirst),MPFROMP(&ri))) { 860 if (!WinSendMsg(hwndCnr,CM_INSERTRECORD, 861 MPFROMP(pciFirst),MPFROMP(&ri))) 862 { 788 863 DosSleep(100L); 789 864 WinSetFocus(HWND_DESKTOP,hwndCnr); 790 if (!WinSendMsg(hwndCnr,CM_INSERTRECORD,865 if (!WinSendMsg(hwndCnr,CM_INSERTRECORD, 791 866 MPFROMP(pciFirst),MPFROMP(&ri))) 792 867 { … … 804 879 Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__, 805 880 GetPString(IDS_FILLDIRERR5TEXT)); 806 totalbytes = -1; 807 if(WinIsWindow((HAB)0,hwndCnr)) { 881 ok = FALSE; 882 ullTotalBytes = 0; 883 if (WinIsWindow((HAB)0,hwndCnr)) 884 { 808 885 pci = pciFirst; 809 while(pci) { 886 while (pci) 887 { 810 888 pcit = (PCNRITEM)pci->rc.preccNextRecord; 811 889 WinSendMsg(hwndCnr,CM_FREERECORD, … … 818 896 } 819 897 } 820 else { 898 else 899 { 821 900 Win_Error(hwndCnr,HWND_DESKTOP,__FILE__,__LINE__, 822 901 GetPString(IDS_FILLDIRERR3TEXT)); 823 totalbytes = -1; 824 } 825 if(totalbytes != -1) { 826 returnbytes += totalbytes; 827 if (returnbytes == -1) 828 returnbytes--; // fixme for real someday 829 if(foundany) 830 (*foundany) += ulMaxFiles; 831 } 832 } 833 } 834 835 if(!fSyncUpdates && dcd && dcd->type == DIR_FRAME) 902 ok = FALSE; 903 ullTotalBytes = 0; 904 } 905 if (ok) 906 { 907 ullReturnBytes += ullTotalBytes; 908 ulReturnFiles += ulFileCnt; 909 } 910 } 911 } 912 913 if (!fSyncUpdates && dcd && dcd->type == DIR_FRAME) 836 914 WinSendMsg(hwndCnr,CM_INVALIDATERECORD,MPVOID, 837 915 MPFROM2SHORT(0,CMA_ERASE)); 838 916 } 839 917 Abort: 840 if(paffbTotal || papffbSelected || paffbFound || pszFileSpec) { 841 if(paffbTotal) 918 if (paffbTotal || papffbSelected || paffbFound || pszFileSpec) 919 { 920 if (paffbTotal) 842 921 free(paffbTotal); 843 if (pszFileSpec)922 if (pszFileSpec) 844 923 free(pszFileSpec); 845 if (paffbFound)924 if (paffbFound) 846 925 free(paffbFound); 847 if (papffbSelected)926 if (papffbSelected) 848 927 free(papffbSelected); 849 928 } 850 if(recurse) { 929 if (recurse) 930 { 851 931 pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pciParent), 852 932 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER)); 853 while(pci && (INT)pci != -1) { 854 if(pci->attrFile & FILE_DIRECTORY) 933 while (pci && (INT)pci != -1) 934 { 935 if (pci->attrFile & FILE_DIRECTORY) 855 936 Stubby(hwndCnr,pci); 856 937 pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci), … … 859 940 } 860 941 861 return returnbytes; 862 } 863 864 865 ULONG FillDirCnr (HWND hwndCnr,CHAR *directory,DIRCNRDATA *dcd) 942 if (pulTotalFiles) 943 *pulTotalFiles = ulReturnFiles; 944 945 if (pullTotalBytes) 946 *pullTotalBytes = ullReturnBytes; 947 948 } // ProcessDirectory 949 950 951 VOID FillDirCnr(HWND hwndCnr, 952 CHAR *pszDirectory, 953 DIRCNRDATA *dcd, 954 PULONGLONG pullTotalBytes) 866 955 { 867 ULONG ret; 868 869 ret = ProcessDirectory(hwndCnr,(PCNRITEM)NULL,directory,TRUE,FALSE,TRUE, 870 (dcd) ? &dcd->stopflag : NULL,dcd,NULL); 956 ProcessDirectory(hwndCnr, 957 (PCNRITEM)NULL, 958 pszDirectory, 959 TRUE, 960 FALSE, 961 TRUE, 962 dcd ? &dcd->stopflag : NULL, 963 dcd, 964 NULL, 965 pullTotalBytes); 871 966 DosPostEventSem(CompactSem); 872 return ret; 873 } 874 875 876 ULONG FillTreeCnr(HWND hwndCnr,HWND hwndParent)967 968 } // FillDirCnr 969 970 971 VOID FillTreeCnr(HWND hwndCnr,HWND hwndParent) 877 972 { 878 973 ULONG ulDriveNum,ulDriveMap,numtoinsert = 0L,drvtype; … … 887 982 fDummy = TRUE; 888 983 *suggest = 0; 889 for (x = 0;x < 26;x++)984 for (x = 0;x < 26;x++) 890 985 driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS | 891 986 DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS | … … 896 991 897 992 DosError(FERR_DISABLEHARDERR); 898 if (!DosQuerySysInfo(QSV_BOOT_DRIVE,899 QSV_BOOT_DRIVE,900 (PVOID)&startdrive,901 (ULONG)sizeof(ULONG)) &&993 if (!DosQuerySysInfo(QSV_BOOT_DRIVE, 994 QSV_BOOT_DRIVE, 995 (PVOID)&startdrive, 996 (ULONG)sizeof(ULONG)) && 902 997 startdrive) 903 998 driveflags[startdrive - 1] |= DRIVE_BOOT; … … 906 1001 rc = DosQCurDisk(&ulDriveNum, 907 1002 &ulDriveMap); 908 if(rc) { 1003 if (rc) 1004 { 909 1005 Dos_Error(MB_CANCEL, 910 1006 rc, … … 916 1012 } 917 1013 for(x = 0;x < 26;x++) 918 if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE))1014 if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) 919 1015 numtoinsert++; 920 if (numtoinsert)1016 if (numtoinsert) 921 1017 pciFirst = WinSendMsg(hwndCnr, 922 1018 CM_ALLOCRECORD, 923 1019 MPFROMLONG(EXTRA_RECORD_BYTES2), 924 1020 MPFROMLONG((ULONG)numtoinsert)); 925 if(pciFirst) { 1021 if (pciFirst) 1022 { 926 1023 pci = pciFirst; 927 1024 for(x = 0;x < 26;x++) { 928 if((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) { 1025 if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) 1026 { 929 1027 *szDrive = (CHAR)x + 'A'; 930 1028 931 1029 { 932 1030 CHAR s[80]; 933 ULONG flags = 0,size = sizeof(ULONG); 1031 ULONG flags = 0; 1032 ULONG size = sizeof(ULONG); 934 1033 935 1034 sprintf(s,"%c.DriveFlags",toupper(*szDrive)); 936 if(PrfQueryProfileData(fmprof,appname,s,&flags,&size) && 937 size == sizeof(ULONG)) 1035 if (PrfQueryProfileData(fmprof,appname,s,&flags,&size) && 1036 size == sizeof(ULONG)) 1037 { 938 1038 driveflags[toupper(*szDrive) - 'A'] |= flags; 939 } 940 941 if(x > 1) { 942 if(!(driveflags[x] & DRIVE_NOPRESCAN)) { 1039 } 1040 } 1041 1042 if (x > 1) 1043 { 1044 if (!(driveflags[x] & DRIVE_NOPRESCAN)) 1045 { 943 1046 *FileSystem = 0; 944 1047 drvtype = 0; 945 1048 removable = CheckDrive(*szDrive,FileSystem,&drvtype); 946 1049 driveserial[x] = -1; 947 if (removable != -1) {948 1050 if (removable != -1) 1051 { 949 1052 struct { 950 1053 ULONG serial; … … 954 1057 955 1058 DosError(FERR_DISABLEHARDERR); 956 if(!DosQueryFSInfo((ULONG)x, 957 FSIL_VOLSER, 958 &volser, 959 sizeof(volser))) 1059 if (!DosQueryFSInfo((ULONG)x, 1060 FSIL_VOLSER, 1061 &volser, 1062 sizeof(volser))) 1063 { 960 1064 driveserial[x] = volser.serial; 1065 } 961 1066 } 962 1067 else … … 965 1070 driveflags[x] |= ((removable == -1 || removable == 1) ? 966 1071 DRIVE_REMOVABLE : 0); 967 if (drvtype & DRIVE_REMOTE)1072 if (drvtype & DRIVE_REMOTE) 968 1073 driveflags[x] |= DRIVE_REMOTE; 969 1074 if (strcmp(FileSystem,HPFS) && … … 975 1080 driveflags[x] |= DRIVE_NOLONGNAMES; 976 1081 } 977 if(!strcmp(FileSystem,CDFS)) { 1082 if (!strcmp(FileSystem,CDFS)) 1083 { 978 1084 removable = 1; 979 1085 driveflags[x] |= DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE | 980 1086 DRIVE_CDROM; 981 1087 } 982 else if (!stricmp(FileSystem,CBSIFS))1088 else if (!stricmp(FileSystem,CBSIFS)) 983 1089 { 984 1090 driveflags[x] |= DRIVE_ZIPSTREAM; 985 1091 driveflags[x] &= ~DRIVE_REMOTE; 986 if (drvtype & DRIVE_REMOVABLE)1092 if (drvtype & DRIVE_REMOVABLE) 987 1093 driveflags[x] |= DRIVE_REMOVABLE; 988 if (!(drvtype & DRIVE_NOLONGNAMES))1094 if (!(drvtype & DRIVE_NOLONGNAMES)) 989 1095 driveflags[x] &= ~DRIVE_NOLONGNAMES; 990 1096 } 991 1097 992 1098 pci->rc.flRecordAttr |= CRA_RECORDREADONLY; 993 if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum)1099 if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum) 994 1100 pci->rc.flRecordAttr |= (CRA_CURSORED | CRA_SELECTED); 995 1101 996 if(removable == 0) { 1102 if (removable == 0) 1103 { 997 1104 pci->attrFile |= FILE_DIRECTORY; 998 1105 DosError(FERR_DISABLEHARDERR); … … 1001 1108 &fsa4, 1002 1109 (ULONG)sizeof(FILESTATUS4)); 1003 if(rc == 58) { 1110 if (rc == 58) 1111 { 1004 1112 DosError(FERR_DISABLEHARDERR); 1005 1113 rc = DosQueryPathInfo(szDrive, … … 1009 1117 fsa4.cbList = 0; 1010 1118 } 1011 if(rc && !didonce) { 1012 if(!*suggest) { 1119 if (rc && !didonce) 1120 { 1121 if (!*suggest) 1122 { 1013 1123 *suggest = '/'; 1014 1124 suggest[1] = 0; … … 1033 1143 NULL); 1034 1144 } 1035 else { 1145 else 1146 { 1036 1147 strcpy(pci->szFileName,szDrive); 1037 1148 pci->pszFileName = pci->szFileName; … … 1042 1153 } 1043 1154 *pci->szFileName = toupper(*pci->szFileName); 1044 if (driveflags[x] & DRIVE_CDROM)1155 if (driveflags[x] & DRIVE_CDROM) 1045 1156 pci->rc.hptrIcon = hptrCDROM; 1046 1157 else … … 1052 1163 hptrZipstrm : hptrDrive; 1053 1164 } 1054 else { 1165 else 1166 { 1055 1167 pci->rc.hptrIcon = hptrDunno; 1056 1168 strcpy(pci->szFileName,szDrive); … … 1063 1175 } 1064 1176 } 1065 else { 1177 else 1178 { 1066 1179 pci->rc.hptrIcon = hptrFloppy; 1067 1180 strcpy(pci->szFileName,szDrive); … … 1077 1190 pci = (PCNRITEM)pci->rc.preccNextRecord; /* next rec */ 1078 1191 } 1079 else if (!(ulDriveMap & (1L << x)))1192 else if (!(ulDriveMap & (1L << x))) 1080 1193 driveflags[x] |= DRIVE_INVALID; 1081 1194 } … … 1086 1199 drivesbuilt = TRUE; 1087 1200 /* insert the drives */ 1088 if (numtoinsert && pciFirst) {1089 1201 if (numtoinsert && pciFirst) 1202 { 1090 1203 RECORDINSERT ri; 1091 1204 … … 1097 1210 ri.cRecordsInsert = numtoinsert; 1098 1211 ri.fInvalidateRecord = FALSE; 1099 if (!WinSendMsg(hwndCnr,1100 CM_INSERTRECORD,1101 MPFROMP(pciFirst),1102 MPFROMP(&ri)))1212 if (!WinSendMsg(hwndCnr, 1213 CM_INSERTRECORD, 1214 MPFROMP(pciFirst), 1215 MPFROMP(&ri))) 1103 1216 Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__, 1104 1217 GetPString(IDS_FILLDIRERR5TEXT)); 1105 1218 } 1106 1219 /* move cursor onto the default drive rather than the first drive */ 1107 if(!fSwitchTree) { 1220 if (!fSwitchTree) 1221 { 1108 1222 pci = (PCNRITEM)WinSendMsg(hwndCnr, 1109 1223 CM_QUERYRECORD, 1110 1224 MPVOID, 1111 1225 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER)); 1112 while(pci && (INT)pci != -1) { 1113 if((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum) { 1226 while(pci && (INT)pci != -1) 1227 { 1228 if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum) 1229 { 1114 1230 WinSendMsg(hwndCnr, 1115 1231 CM_SETRECORDEMPHASIS, … … 1125 1241 } 1126 1242 1127 if (hwndParent)1243 if (hwndParent) 1128 1244 WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT), 1129 1245 MAIN_DRIVELIST), … … 1132 1248 MPVOID); 1133 1249 1134 if (fShowEnv) {1135 1250 if (fShowEnv) 1251 { 1136 1252 RECORDINSERT ri; 1137 1253 … … 1140 1256 MPFROMLONG(EXTRA_RECORD_BYTES2), 1141 1257 MPFROMLONG(1)); 1142 if(pciParent) { 1258 if (pciParent) 1259 { 1143 1260 pciParent->flags |= RECFLAGS_ENV; 1144 1261 strcpy(pciParent->szFileName,GetPString(IDS_ENVVARSTEXT)); … … 1155 1272 ri.cRecordsInsert = 1; 1156 1273 ri.fInvalidateRecord = FALSE; 1157 if (WinSendMsg(hwndCnr,1158 CM_INSERTRECORD,1159 MPFROMP(pciParent),1160 MPFROMP(&ri))) {1274 if (WinSendMsg(hwndCnr, 1275 CM_INSERTRECORD, 1276 MPFROMP(pciParent), 1277 MPFROMP(&ri))) { 1161 1278 1162 1279 char *p,*pp; … … 1165 1282 while(*p == ' ') 1166 1283 p++; 1167 while(*p) { 1284 while (*p) 1285 { 1168 1286 *FileSystem = 0; 1169 1287 pp = FileSystem; … … 1173 1291 while(*p == ' ') 1174 1292 p++; 1175 if(*FileSystem && 1176 (!stricmp(FileSystem,"LIBPATH") || 1177 getenv(FileSystem))) { 1293 if (*FileSystem && 1294 (!stricmp(FileSystem,"LIBPATH") || 1295 getenv(FileSystem))) 1296 { 1178 1297 pci = WinSendMsg(hwndCnr, 1179 1298 CM_ALLOCRECORD, 1180 1299 MPFROMLONG(EXTRA_RECORD_BYTES2), 1181 1300 MPFROMLONG(1)); 1182 if(pci) { 1301 if (pci) 1302 { 1183 1303 pci->flags |= RECFLAGS_ENV; 1184 1304 sprintf(pci->szFileName, … … 1197 1317 ri.cRecordsInsert = 1; 1198 1318 ri.fInvalidateRecord = FALSE; 1199 if (!WinSendMsg(hwndCnr,1200 CM_INSERTRECORD,1201 MPFROMP(pci),1202 MPFROMP(&ri))) {1319 if (!WinSendMsg(hwndCnr, 1320 CM_INSERTRECORD, 1321 MPFROMP(pci), 1322 MPFROMP(&ri))) { 1203 1323 Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__, 1204 1324 GetPString(IDS_FILLDIRERR5TEXT)); … … 1228 1348 CM_QUERYRECORD, 1229 1349 MPVOID, 1230 MPFROM2SHORT(CMA_FIRST, 1231 CMA_ITEMORDER));1232 while(pci && (INT)pci != -1){1350 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 1351 while (pci && (INT)pci != -1) 1352 { 1233 1353 pciNext = (PCNRITEM)WinSendMsg(hwndCnr, 1234 1354 CM_QUERYRECORD, 1235 1355 MPFROMP(pci), 1236 MPFROM2SHORT(CMA_NEXT, 1237 CMA_ITEMORDER)); 1238 if(!(pci->flags & RECFLAGS_ENV)) { 1239 if((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum || 1240 toupper(*pci->szFileName) > 'B') { 1241 if(!(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_INVALID) && 1356 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 1357 if (!(pci->flags & RECFLAGS_ENV)) 1358 { 1359 if ((ULONG)(toupper(*pci->szFileName) - '@') == ulDriveNum || 1360 toupper(*pci->szFileName) > 'B') 1361 { 1362 if (!(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_INVALID) && 1242 1363 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_NOPRESCAN) && 1243 1364 (!fNoRemovableScan || 1244 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE))) { 1245 if(!Stubby(hwndCnr,pci)) { 1365 !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE))) 1366 { 1367 if (!Stubby(hwndCnr,pci)) 1368 { 1246 1369 WinSendMsg(hwndCnr, 1247 1370 CM_INVALIDATERECORD, … … 1257 1380 MPFROMP(&pci), 1258 1381 MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION)); 1382 1259 1383 WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT), 1260 1384 MAIN_DRIVELIST), … … 1267 1391 pci = pciNext; 1268 1392 } 1269 if (hwndParent)1393 if (hwndParent) 1270 1394 WinSendMsg(WinWindowFromID(WinQueryWindow(hwndParent,QW_PARENT), 1271 1395 MAIN_DRIVELIST),LM_SELECTITEM,MPFROM2SHORT(0,0), … … 1277 1401 MPFROM2SHORT(CMA_FIRST, 1278 1402 CMA_ITEMORDER)); 1279 while(pci && (INT)pci != -1) { 1403 while (pci && (INT)pci != -1) 1404 { 1280 1405 pciNext = (PCNRITEM)WinSendMsg(hwndCnr, 1281 1406 CM_QUERYRECORD, … … 1283 1408 MPFROM2SHORT(CMA_NEXT, 1284 1409 CMA_ITEMORDER)); 1285 if(pci->flags & RECFLAGS_ENV) { 1410 if (pci->flags & RECFLAGS_ENV) 1411 { 1286 1412 pci = (PCNRITEM)WinSendMsg(hwndCnr, 1287 1413 CM_QUERYRECORD, … … 1289 1415 MPFROM2SHORT(CMA_FIRSTCHILD, 1290 1416 CMA_ITEMORDER)); 1291 while(pci && (INT)pci != -1) { 1292 if(pci->flags & RECFLAGS_ENV) 1417 while (pci && (INT)pci != -1) 1418 { 1419 if (pci->flags & RECFLAGS_ENV) 1293 1420 FleshEnv(hwndCnr,pci); 1294 1421 pci = (PCNRITEM)WinSendMsg(hwndCnr, … … 1308 1435 1309 1436 } 1310 else { 1437 else 1438 { 1311 1439 Win_Error(hwndCnr,hwndCnr,__FILE__,__LINE__, 1312 1440 GetPString(IDS_FILLDIRERR7TEXT)); 1313 1441 exit(0); 1314 1442 } 1315 if (!drivesbuilt && hwndMain)1443 if (!drivesbuilt && hwndMain) 1316 1444 PostMsg(hwndMain, 1317 1445 UM_BUILDDRIVES, … … 1325 1453 BOOL includesyours = FALSE; 1326 1454 1327 if(*suggest || 1328 (!(driveflags[1] & DRIVE_IGNORE) && 1329 fFirstTime)) { 1330 if(!DosDevConfig(&info, 1455 if (*suggest || 1456 (!(driveflags[1] & DRIVE_IGNORE) && 1457 fFirstTime)) 1458 { 1459 if (!DosDevConfig(&info, 1331 1460 DEVINFO_FLOPPY) && 1332 info == 1) { 1333 if(!*suggest) { 1461 info == 1) 1462 { 1463 if (!*suggest) 1464 { 1334 1465 *suggest = '/'; 1335 1466 suggest[1] = 0; … … 1340 1471 } 1341 1472 } 1342 if(*suggest) { 1343 for(x = 2;x < 26;x++) { 1344 if(driveflags[x] & DRIVE_IGNORE) { 1473 if (*suggest) 1474 { 1475 for(x = 2;x < 26;x++) 1476 { 1477 if (driveflags[x] & DRIVE_IGNORE) 1478 { 1345 1479 includesyours = TRUE; 1346 1480 sprintf(suggest + strlen(suggest), … … 1350 1484 } 1351 1485 strcat(suggest," %*"); 1352 if(saymsg(MB_YESNO | MB_ICONEXCLAMATION, 1353 (hwndParent) ? hwndParent : hwndCnr, 1354 GetPString(IDS_SUGGESTTITLETEXT), 1355 GetPString(IDS_SUGGEST1TEXT), 1356 (includesyours) ? 1357 GetPString(IDS_SUGGEST2TEXT) : 1358 NullStr, 1359 suggest) == MBID_YES) { 1360 1486 if (saymsg(MB_YESNO | MB_ICONEXCLAMATION, 1487 (hwndParent) ? hwndParent : hwndCnr, 1488 GetPString(IDS_SUGGESTTITLETEXT), 1489 GetPString(IDS_SUGGEST1TEXT), 1490 (includesyours) ? GetPString(IDS_SUGGEST2TEXT) : NullStr, 1491 suggest) == MBID_YES) 1492 { 1361 1493 char s[64]; 1362 1494 1363 sprintf(s, 1364 "PARAMETERS=%s", 1365 suggest); 1495 sprintf(s, "PARAMETERS=%s", suggest); 1366 1496 WinCreateObject(WPProgram, 1367 1497 "FM/2", … … 1408 1538 } 1409 1539 didonce = TRUE; 1410 return 0; 1411 } 1412 1540 1541 } // FillTreeCnr 1542  
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  