Changeset 783
- Timestamp:
- Aug 14, 2007, 6:09:54 AM (18 years ago)
- Location:
- trunk/dll
- Files:
-
- 10 edited
-
comp.c (modified) (11 diffs)
-
dirsize.c (modified) (15 diffs)
-
filldir.c (modified) (31 diffs)
-
fm3res.dlg (modified) (2 diffs)
-
grep.c (modified) (52 diffs)
-
init.c (modified) (4 diffs)
-
ipf/notebook.ipf (modified) (4 diffs)
-
notebook.c (modified) (9 diffs)
-
objcnr.c (modified) (11 diffs)
-
seeall.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/comp.c
r775 r783 31 31 07 Aug 07 SHL COMP_COLLECT: Avoid collecting empty entries when nothing selected 32 32 06 Aug 07 GKY Reduce DosSleep times (ticket 148) 33 33 13 Aug 07 SHL Sync code with other FilesToGet usage 34 13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat 34 35 35 36 ***********************************************************************/ … … 37 38 #define INCL_DOS 38 39 #define INCL_WIN 40 #define INCL_DOSERRORS 39 41 #define INCL_GPI 40 42 #define INCL_LONGLONG … … 52 54 #include "fm3dlg.h" 53 55 #include "fm3str.h" 54 55 #pragma alloc_text(COMPAREDIR,FillCnrsThread,FillDirList,CompNames,BldFullPathName)56 #pragma alloc_text(COMPAREDIR1,CompareDlgProc)57 #pragma alloc_text(COMPAREDIR2,SelectCnrsThread,ActionCnrThread)58 #pragma alloc_text(COMPAREFILE,CFileDlgProc,CompareFilesThread)59 #pragma alloc_text(SNAPSHOT,SnapShot,StartSnap)60 56 61 57 typedef struct … … 92 88 //=== SnapShot() Write directory tree to file and recurse if requested === 93 89 94 static VOID SnapShot(char *path, FILE * fp, BOOL recurse)90 static VOID SnapShot(char *path, FILE *fp, BOOL recurse) 95 91 { 96 FILEFINDBUF4 *fb;92 PFILEFINDBUF4 pffb; 97 93 char *mask, *enddir; 98 94 HDIR hdir = HDIR_CREATE; 99 ULONG nm = 1; 100 101 fb = xmalloc(sizeof(FILEFINDBUF4), pszSrcFile, __LINE__); 102 if (fb) { 95 ULONG ulFindCnt; 96 97 // 13 Aug 07 SHL fimxe to use FileToGet 98 pffb = xmalloc(sizeof(FILEFINDBUF4), pszSrcFile, __LINE__); 99 if (pffb) { 103 100 mask = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__); 104 101 if (mask) { 105 sprintf(mask, 106 "%s%s*", 107 path, (path[strlen(path) - 1] != '\\') ? "\\" : NullStr); 102 BldFullPathName(mask, path, "*"); 103 // sprintf(mask, 104 // "%s%s*", 105 // path, (path[strlen(path) - 1] != '\\') ? "\\" : NullStr); 108 106 enddir = strrchr(mask, '\\'); 109 107 enddir++; 108 ulFindCnt = 1; 109 // 13 Aug 07 SHL fixme to report errors 110 110 if (!DosFindFirst(mask, 111 111 &hdir, … … 113 113 FILE_ARCHIVED | FILE_READONLY | FILE_HIDDEN | 114 114 FILE_SYSTEM, 115 fb, sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE)) {115 pffb, sizeof(FILEFINDBUF4), &ulFindCnt, FIL_QUERYEASIZE)) { 116 116 do { 117 strcpy(enddir, fb->achName);118 if (!( fb->attrFile & FILE_DIRECTORY))117 strcpy(enddir, pffb->achName); 118 if (!(pffb->attrFile & FILE_DIRECTORY)) 119 119 fprintf(fp, 120 120 "\"%s\",%u,%lu,%04u/%02u/%02u,%02u:%02u:%02u,%lu,%lu,N\n", 121 121 mask, 122 122 enddir - mask, 123 fb->cbFile,124 ( fb->fdateLastWrite.year + 1980),125 fb->fdateLastWrite.month,126 fb->fdateLastWrite.day,127 fb->ftimeLastWrite.hours,128 fb->ftimeLastWrite.minutes,129 fb->ftimeLastWrite.twosecs,130 fb->attrFile, (fb->cbList > 4) ? (fb->cbList / 2) : 0);123 pffb->cbFile, 124 (pffb->fdateLastWrite.year + 1980), 125 pffb->fdateLastWrite.month, 126 pffb->fdateLastWrite.day, 127 pffb->ftimeLastWrite.hours, 128 pffb->ftimeLastWrite.minutes, 129 pffb->ftimeLastWrite.twosecs, 130 pffb->attrFile, (pffb->cbList > 4) ? (pffb->cbList / 2) : 0); 131 131 // Skip . and .. 132 132 else if (recurse && 133 ( fb->achName[0] != '.' ||134 ( fb->achName[1] &&135 ( fb->achName[1] != '.' ||fb->achName[2])))) {133 (pffb->achName[0] != '.' || 134 (pffb->achName[1] && 135 (pffb->achName[1] != '.' || pffb->achName[2])))) { 136 136 SnapShot(mask, fp, recurse); 137 137 } 138 nm= 1;139 } while (!DosFindNext(hdir, fb, sizeof(FILEFINDBUF4), &nm));138 ulFindCnt = 1; 139 } while (!DosFindNext(hdir, pffb, sizeof(FILEFINDBUF4), &ulFindCnt)); 140 140 DosFindClose(hdir); 141 141 } 142 142 free(mask); 143 143 } 144 free( fb);144 free(pffb); 145 145 } 146 146 } … … 683 683 HMQ hmq; 684 684 685 if (!cmp) 685 if (!cmp) { 686 Runtime_Error(pszSrcFile, __LINE__, "no data"); 686 687 return; 688 } 687 689 688 690 DosError(FERR_DISABLEHARDERR); … … 729 731 FILELIST ***list, INT *numfiles, INT *numalloc) 730 732 { 731 732 BYTE *fb;733 733 CHAR *enddir; 734 734 ULONG x; 735 735 CHAR *maskstr; 736 FILEFINDBUF4 *ffb4, *pffb; 736 PFILEFINDBUF4 pffbArray; 737 PFILEFINDBUF4 pffbFile; 737 738 HDIR hDir; 738 ULONG nm, fl = 0, ulM = FilesToGet; 739 ULONG ulFindCnt; 740 ULONG ulBufBytes = sizeof(FILEFINDBUF4) * FilesToGet; 739 741 APIRET rc; 740 742 … … 744 746 } 745 747 746 //if (!recurse)747 // ulM = FilesToGet;748 748 maskstr = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__); 749 749 if (!maskstr) 750 750 return; 751 ffb4 = xmalloc(sizeof(FILEFINDBUF4) * ulM, pszSrcFile, __LINE__);752 if (! ffb4) {751 pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__); 752 if (!pffbArray) { 753 753 free(maskstr); 754 754 return; … … 765 765 *(enddir + 1) = 0; 766 766 hDir = HDIR_CREATE; 767 nm = ulM;768 if (recurse)769 fl = FILE_DIRECTORY;770 767 DosError(FERR_DISABLEHARDERR); 768 ulFindCnt = FilesToGet; 771 769 rc = DosFindFirst(maskstr, &hDir, 772 (FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | 773 FILE_SYSTEM | FILE_HIDDEN) | fl, 774 ffb4, sizeof(FILEFINDBUF4) * nm, &nm, FIL_QUERYEASIZE); 770 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | 771 FILE_SYSTEM | FILE_HIDDEN | 772 (recurse ? FILE_DIRECTORY : 0), 773 pffbArray, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZE); 775 774 if (!rc) { 776 while (!rc) { 777 fb = (BYTE *) ffb4; 778 x = 0; 779 while (x < nm) { 780 pffb = (FILEFINDBUF4 *) fb; 781 if (pffb->attrFile & FILE_DIRECTORY) { 775 do { 776 pffbFile = pffbArray; 777 for (x = 0; x < ulFindCnt; x++) { 778 if (pffbFile->attrFile & FILE_DIRECTORY) { 782 779 // Skip . and .. 783 780 if (recurse && 784 (pffb ->achName[0] != '.' ||785 (pffb ->achName[1] &&786 (pffb ->achName[1] != '.' || pffb->achName[2])))) {781 (pffbFile->achName[0] != '.' || 782 (pffbFile->achName[1] && 783 (pffbFile->achName[1] != '.' || pffbFile->achName[2])))) { 787 784 if (fForceUpper) 788 strupr(pffb ->achName);785 strupr(pffbFile->achName); 789 786 else if (fForceLower) 790 strlwr(pffb ->achName);791 memcpy(enddir, pffb ->achName, pffb->cchName + 1);787 strlwr(pffbFile->achName); 788 memcpy(enddir, pffbFile->achName, pffbFile->cchName + 1); 792 789 FillDirList(maskstr, skiplen, recurse, list, numfiles, numalloc); 793 790 } … … 795 792 else { 796 793 if (fForceUpper) 797 strupr(pffb ->achName);794 strupr(pffbFile->achName); 798 795 else if (fForceLower) 799 strlwr(pffb ->achName);800 memcpy(enddir, pffb ->achName, pffb->cchName + 1);801 if (AddToFileList 802 (maskstr + skiplen, pffb, list, numfiles, numalloc))796 strlwr(pffbFile->achName); 797 memcpy(enddir, pffbFile->achName, pffbFile->cchName + 1); 798 if (AddToFileList(maskstr + skiplen, 799 pffbFile, list, numfiles, numalloc)) { 803 800 goto Abort; 804 } 805 fb += pffb->oNextEntryOffset; 806 x++; 807 } 808 nm = ulM; 801 } 802 } 803 pffbFile = (PFILEFINDBUF4)((PBYTE)pffbFile + pffbFile->oNextEntryOffset); 804 } // for 809 805 DosError(FERR_DISABLEHARDERR); 810 rc = DosFindNext(hDir, ffb4, sizeof(FILEFINDBUF4) * nm, &nm); 811 } 812 Abort: 806 ulFindCnt = FilesToGet; 807 rc = DosFindNext(hDir, pffbArray, ulBufBytes, &ulFindCnt); 808 } while (!rc); 809 810 Abort: 811 813 812 DosFindClose(hDir); 814 813 DosSleep(1); 815 814 } 815 816 if (rc && rc != ERROR_NO_MORE_FILES) { 817 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 818 GetPString(IDS_CANTFINDDIRTEXT), maskstr); 819 } 820 816 821 free(maskstr); 817 free( ffb4);822 free(pffbArray); 818 823 } 819 824 … … 2500 2505 return WinDefDlgProc(hwnd, msg, mp1, mp2); 2501 2506 } 2507 2508 #pragma alloc_text(COMPAREDIR,FillCnrsThread,FillDirList,CompNames,BldFullPathName) 2509 #pragma alloc_text(COMPAREDIR1,CompareDlgProc) 2510 #pragma alloc_text(COMPAREDIR2,SelectCnrsThread,ActionCnrThread) 2511 #pragma alloc_text(COMPAREFILE,CFileDlgProc,CompareFilesThread) 2512 #pragma alloc_text(SNAPSHOT,SnapShot,StartSnap) 2513 -
trunk/dll/dirsize.c
r781 r783 28 28 03 Aug 07 SHL DirSizeProc; correct sizing and positioning to be deterministic 29 29 06 Aug 07 GKY Reduce DosSleep times (ticket 148) 30 11 Aug 07 SHL ProcessDir: remove unneeded reallocs 30 13 Aug 07 SHL ProcessDir: remove unneeded reallocs. Sanitize code 31 13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat 31 32 32 33 ***********************************************************************/ … … 68 69 static PSZ pszSrcFile = __FILE__; 69 70 70 #pragma alloc_text(DIRSIZE,ProcessDir,FillCnrThread,DirSizeProc) 71 #pragma alloc_text(DIRSIZE2,PrintToFile,FillInRecSizes,SortSizeCnr) 72 73 static SHORT APIENTRY SortSizeCnr(PMINIRECORDCORE p1, PMINIRECORDCORE p2, 71 static SHORT APIENTRY SortSizeCnr(PMINIRECORDCORE p1, 72 PMINIRECORDCORE p2, 74 73 PVOID SortFlags) 75 74 { … … 95 94 register char *sp; 96 95 register char *pp; 97 ULONG nm;96 ULONG ulFindCnt; 98 97 ULONGLONG ullCurDirBytes = 0; 99 98 ULONGLONG ullSubDirBytes = 0; 100 99 ULONGLONG ull; 101 100 HDIR hdir; 102 FILEFINDBUF4 *pffb;101 PFILEFINDBUF4 pffbArray; 103 102 APIRET rc; 104 103 RECORDINSERT ri; 105 104 PCNRITEM pci; 106 107 // fixme to report errors 105 ULONG ulBufBytes; 106 108 107 *pullTotalBytes = 0; // In case we fail 109 108 110 pffb = xmalloc(sizeof(FILEFINDBUF4) * FilesToGet, pszSrcFile, __LINE__); 111 if (!pffb) 109 ulBufBytes = sizeof(FILEFINDBUF4) * FilesToGet; 110 pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__); 111 if (!pffbArray) 112 112 return FALSE; // Error already reported 113 113 … … 119 119 120 120 hdir = HDIR_CREATE; 121 nm = 1; 122 // 11 Aug 07 SHL fixme to know if we can bypass memset 123 memset(pffb, 0, sizeof(FILEFINDBUF4)); 121 ulFindCnt = 1; 122 // memset(pffbArray, 0, sizeof(FILEFINDBUF4)); // 11 Aug 07 SHL bypass memset 124 123 DosError(FERR_DISABLEHARDERR); 125 124 // Check directory exists … … 127 126 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | 128 127 FILE_SYSTEM | FILE_HIDDEN | MUST_HAVE_DIRECTORY, 129 pffb , sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE);128 pffbArray, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZE); 130 129 131 130 if (!rc) … … 137 136 * requesting EASIZE. sheesh. 138 137 */ 139 if ((!rc && (pffb ->attrFile & FILE_DIRECTORY)) || strlen(pszFileName) < 4) {138 if ((!rc && (pffbArray->attrFile & FILE_DIRECTORY)) || strlen(pszFileName) < 4) { 140 139 if (*pchStopFlag) { 141 free(pffb );140 free(pffbArray); 142 141 return FALSE; 143 142 } … … 145 144 MPFROMLONG(1)); 146 145 if (!pci) { 147 free(pffb); 146 Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_ALLOCRECORD"); 147 free(pffbArray); 148 148 return FALSE; 149 149 } 150 150 if (!rc) { 151 ullCurDirBytes = pffb ->cbFile;152 ullCurDirBytes += CBLIST_TO_EASIZE(pffb ->cbList);151 ullCurDirBytes = pffbArray->cbFile; 152 ullCurDirBytes += CBLIST_TO_EASIZE(pffbArray->cbList); 153 153 } 154 154 else … … 161 161 else { 162 162 // No match 163 free(pffb );163 free(pffbArray); 164 164 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 165 165 GetPString(IDS_CANTFINDDIRTEXT), pszFileName); … … 186 186 pci->pszFileName = xstrdup(szBuf, pszSrcFile, __LINE__); 187 187 } 188 // fixme to know why - itappears to be indirectly saving length, but why?188 // fixme to understand this - appears to be indirectly saving length, but why? 189 189 pci->pszDisplayName = pci->pszFileName + strlen(pci->pszFileName); 190 190 pci->pszLongName = pci->pszFileName; // fixme to be sure? … … 204 204 ri.fInvalidateRecord = TRUE; 205 205 if (!WinSendMsg(hwndCnr, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) { 206 free(pffb );206 free(pffbArray); 207 207 return FALSE; 208 208 } … … 210 210 // Find files and directories in this directory 211 211 hdir = HDIR_CREATE; 212 nm = FilesToGet; 212 // 13 Aug 07 SHL fixme to know if need to support fRemoteBug here like objcnr.c? 213 ulFindCnt = FilesToGet; 213 214 rc = DosFindFirst(maskstr, &hdir, 214 215 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | 215 216 FILE_SYSTEM | FILE_HIDDEN | FILE_DIRECTORY, 216 pffb , nm * sizeof(FILEFINDBUF4), &nm, FIL_QUERYEASIZE);217 pffbArray, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZE); 217 218 if (!rc) { 218 PBYTE fb = (PBYTE)pffb; 219 FILEFINDBUF4 *pffbFile; 219 PFILEFINDBUF4 pffbFile; 220 220 ULONG x; 221 221 222 222 while (!rc) { 223 224 #if 0 // 13 Aug 07 SHL fixme to be gone 225 { 226 static ULONG ulMaxCnt = 1; 227 if (ulFindCnt > ulMaxCnt) { 228 ulMaxCnt = ulFindCnt; 229 DbgMsg(pszSrcFile, __LINE__, "ulMaxCnt %u/%u", ulMaxCnt, FilesToGet); 230 } 231 } 232 #endif 233 223 234 priority_normal(); 224 for (x = 0; x < nm; x++) {225 pffbFile = (FILEFINDBUF4 *)fb; 235 pffbFile = pffbArray; 236 for (x = 0; x < ulFindCnt; x++) { 226 237 // Total size skipping . and .. 227 238 if ((~pffbFile->attrFile & FILE_DIRECTORY) || … … 232 243 ullCurDirBytes += CBLIST_TO_EASIZE(pffbFile->cbList) & 0x3ff; 233 244 234 if (!(pffbFile->attrFile & FILE_DIRECTORY))235 pci->attrFile++; // Bump file count236 245 if (*pchStopFlag) 237 246 break; 238 if (pffbFile->attrFile & FILE_DIRECTORY) { 247 if (~pffbFile->attrFile & FILE_DIRECTORY) 248 pci->attrFile++; // Bump file count 249 else { 239 250 // Recurse into subdir 240 251 strcpy(pEndMask, pffbFile->achName); // Append dirname to base dirname 241 if (!*pchStopFlag) { 242 ProcessDir(hwndCnr, maskstr, pci, pchStopFlag, FALSE, &ull); 243 ullSubDirBytes += ull; 244 } 252 ProcessDir(hwndCnr, maskstr, pci, pchStopFlag, FALSE, &ull); 253 ullSubDirBytes += ull; 245 254 } 246 255 } 247 256 if (!pffbFile->oNextEntryOffset) 248 257 break; 249 fb += pffbFile->oNextEntryOffset; 258 pffbFile = (PFILEFINDBUF4)((PBYTE)pffbFile + pffbFile->oNextEntryOffset); 259 260 #if 0 // 13 Aug 07 SHL fixme to be gone 261 { 262 static ULONG ulMaxBytes = 65535; 263 ULONG ul = (PBYTE)pffbFile - (PBYTE)pffbArray; 264 if (ul > ulMaxBytes) { 265 ulMaxBytes = ul; 266 DbgMsg(pszSrcFile, __LINE__, "ulFindCnt %u/%u ulMaxBytes %u/%u", 267 ulFindCnt, FilesToGet, ulMaxBytes, ulBufBytes); 268 } 269 } 270 #endif 271 250 272 } // for matches 251 273 if (*pchStopFlag) 252 274 break; 253 DosSleep( 1);254 nm= FilesToGet;275 DosSleep(0); 276 ulFindCnt = FilesToGet; 255 277 DosError(FERR_DISABLEHARDERR); 256 rc = DosFindNext(hdir, pffb , sizeof(FILEFINDBUF4) * FilesToGet, &nm);278 rc = DosFindNext(hdir, pffbArray, ulBufBytes, &ulFindCnt); 257 279 } // while more found 258 259 if (rc != ERROR_NO_MORE_FILES) {260 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,261 GetPString(IDS_CANTFINDDIRTEXT), pszFileName);262 }263 280 264 281 DosFindClose(hdir); … … 266 283 } // if got files or directories 267 284 268 free(pffb); 285 if (rc && rc != ERROR_NO_MORE_FILES) { 286 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 287 GetPString(IDS_CANTFINDDIRTEXT), pszFileName); 288 } 289 290 free(pffbArray); 269 291 270 292 pci->cbFile = ullCurDirBytes; … … 407 429 } 408 430 409 static VOID FillCnrThread(VOID * args)431 static VOID FillCnrThread(VOID *args) 410 432 { 411 433 HAB hab; 412 434 HMQ hmq; 413 DIRSIZE *dirsize = (DIRSIZE *) args;435 DIRSIZE *dirsize = (DIRSIZE *)args; 414 436 HWND hwndCnr; 415 437 ULONGLONG ull; 416 438 417 if (!dirsize) 439 if (!dirsize) { 440 Runtime_Error(pszSrcFile, __LINE__, "no data"); 418 441 return; 442 } 443 419 444 hwndCnr = dirsize->hwndCnr; 420 445 … … 965 990 return WinDefDlgProc(hwnd, msg, mp1, mp2); 966 991 } 992 993 #pragma alloc_text(DIRSIZE,ProcessDir,FillCnrThread,DirSizeProc) 994 #pragma alloc_text(DIRSIZE2,PrintToFile,FillInRecSizes,SortSizeCnr) 995 -
trunk/dll/filldir.c
r775 r783 37 37 04 Aug 07 SHL Update #pragma alloc_test for new functions 38 38 06 Aug 07 GKY Reduce DosSleep times (ticket 148) 39 13 Aug 07 SHL Sync code with other FilesToGet usage and optimize 40 13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat 39 41 40 42 ***********************************************************************/ … … 42 44 #define INCL_DOS 43 45 #define INCL_WIN 46 #define INCL_DOSERRORS 44 47 #define INCL_LONGLONG 45 48 #include <os2.h> … … 53 56 #include <time.h> 54 57 55 #if 1// fixme to disable or to be configurable58 #if 0 // fixme to disable or to be configurable 56 59 #include <malloc.h> // _heapchk 57 60 #endif … … 61 64 62 65 static PSZ pszSrcFile = __FILE__; 63 64 #pragma alloc_text(FILLDIR,FillInRecordFromFFB,FillInRecordFromFSA,IDFile)65 #pragma alloc_text(FILLDIR1,ProcessDirectory,FillDirCnr,FillTreeCnr,FileAttrToString)66 #pragma alloc_text(EMPTYCNR,EmptyCnr,FreeCnrItemData,FreeCnrItem,FreeCnrItemList,RemoveCnrItems)67 66 68 67 /** … … 240 239 DIRCNRDATA *dcd) 241 240 { 242 / * fill in a container record from a FILEFINDBUF4 structure */241 // fill in a container record from a FILEFINDBUF4 structure 243 242 244 243 CHAR *p; … … 271 270 } 272 271 273 / * load the object's Subject, if required */272 // load the object's Subject, if required 274 273 pci->pszSubject = NullStr; 275 274 if (pffb->cbList > 4L && … … 316 315 pci->pszSubject = NullStr; 317 316 318 / * load the object's longname */317 // load the object's longname 319 318 pci->pszLongName = 0; 320 319 if (fLoadLongnames && … … 363 362 pci->pszLongName = NullStr; 364 363 365 / * do anything required to case of filename */364 // do anything required to case of filename 366 365 if (fForceUpper) 367 366 strupr(pci->pszFileName); … … 369 368 strlwr(pci->pszFileName); 370 369 371 / * get an icon to use with it */370 // get an icon to use with it 372 371 if (pffb->attrFile & FILE_DIRECTORY) { 373 372 // is directory … … 425 424 pci->pszDisplayName = p; 426 425 427 / * now fill the darned thing in... */426 // now fill the darned thing in... 428 427 pci->date.day = pffb->fdateLastWrite.day; 429 428 pci->date.month = pffb->fdateLastWrite.month; … … 451 450 pci->rc.hptrIcon = hptr; 452 451 453 / * check to see if record should be visible */452 // check to see if record should be visible 454 453 if (dcd && (*dcd->mask.szMask || dcd->mask.antiattr || 455 454 ((dcd->mask.attrFile & … … 483 482 CHAR *p; 484 483 485 / * fill in a container record from a FILESTATUS4 structure */484 // fill in a container record from a FILESTATUS4 structure 486 485 487 486 pci->hwndCnr = hwndCnr; … … 489 488 strcpy(pci->pszFileName, pszFileName); 490 489 491 / * load the object's Subject, if required */490 // load the object's Subject, if required 492 491 pci->pszSubject = NullStr; 493 492 if (pfsa4->cbList > 4L && … … 708 707 PFILEFINDBUF4 paffbTemp; 709 708 HDIR hdir = HDIR_CREATE; 710 ULONG ulFi leCnt;711 ULONG ul ExtraBytes;712 ULONG ul M = 1;709 ULONG ulFindCnt; 710 ULONG ulFindMax; 711 ULONG ulSelCnt; 713 712 ULONG ulTotal = 0; 714 713 ULONGLONG ullBytes; … … 721 720 PCNRITEM pciFirst; 722 721 RECORDINSERT ri; 723 PBYTE pByte;724 PBYTE pByte2;725 722 BOOL ok = TRUE; 723 ULONG ulBufBytes; 724 ULONG x; 726 725 727 726 if (isalpha(*szDirBase) && szDirBase[1] == ':' && szDirBase[2] == '\\') { 728 ulExtraBytes = EXTRA_RECORD_BYTES;729 727 if ((driveflags[toupper(*szDirBase) - 'A'] & DRIVE_REMOTE) && fRemoteBug) 730 ul M = 1; /* file system gets confused */728 ulFindMax = 1; // file system gets confused 731 729 else if (driveflags[toupper(*szDirBase) - 'A'] & DRIVE_ZIPSTREAM) 732 ul M = min(FilesToGet, 225); /* anything more is wasted */730 ulFindMax = min(FilesToGet, 225); // anything more is wasted 733 731 else 734 ul M = FilesToGet; /* full-out */732 ulFindMax = FilesToGet; // full-out 735 733 } 736 734 else { 737 ulExtraBytes = EXTRA_RECORD_BYTES; 738 ulM = FilesToGet; 735 ulFindMax = FilesToGet; 739 736 } 740 737 if (OS2ver[0] == 20 && OS2ver[1] < 30) 741 ulM = min(ulM, (65535 / sizeof(FILEFINDBUF4))); 742 743 ulFileCnt = ulM; 738 ulFindMax = min(ulFindMax, (65535 / sizeof(FILEFINDBUF4))); 739 740 ulBufBytes = ulFindMax * sizeof(FILEFINDBUF4); 741 744 742 pszFileSpec = xmalloc(CCHMAXPATH + 2, pszSrcFile, __LINE__); 745 paffbFound = 746 xmalloc((ulM + 1) * sizeof(FILEFINDBUF4), pszSrcFile, __LINE__); 747 papffbSelected = 748 xmalloc((ulM + 1) * sizeof(PFILEFINDBUF4), pszSrcFile, __LINE__); 743 paffbFound = xmalloc(ulBufBytes, pszSrcFile, __LINE__); 744 papffbSelected = xmalloc(sizeof(PFILEFINDBUF4) * ulFindMax, pszSrcFile, __LINE__); 745 749 746 if (paffbFound && papffbSelected && pszFileSpec) { 750 747 t = strlen(szDirBase); … … 757 754 memcpy(pchEndPath, "*", 2); 758 755 DosError(FERR_DISABLEHARDERR); 759 rc = DosFindFirst(pszFileSpec, &hdir, 760 FILE_NORMAL | ((filestoo) ? FILE_DIRECTORY : 761 MUST_HAVE_DIRECTORY) | FILE_READONLY | 762 FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN, 763 paffbFound, ulM * sizeof(FILEFINDBUF4), 764 &ulFileCnt, FIL_QUERYEASIZE); 756 ulFindCnt = ulFindMax; 757 rc = DosFindFirst(pszFileSpec, 758 &hdir, 759 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | 760 FILE_SYSTEM | FILE_HIDDEN | 761 (filestoo ? FILE_DIRECTORY : MUST_HAVE_DIRECTORY), 762 paffbFound, 763 ulBufBytes, 764 &ulFindCnt, 765 FIL_QUERYEASIZE); 765 766 priority_normal(); 766 767 *pchEndPath = 0; 767 768 if (!rc) { 768 while (!rc){769 do { 769 770 /* 770 771 * remove . and .. from list if present … … 774 775 * network file systems exhibit such a problem). 775 776 */ 776 register ULONG x; 777 #if 0 // 13 Aug 07 SHL fixme to be gone 778 { 779 static ULONG ulMaxCnt = 1; 780 if (ulFindCnt > ulMaxCnt) { 781 ulMaxCnt = ulFindCnt; 782 DbgMsg(pszSrcFile, __LINE__, "ulMaxCnt %u/%u", ulMaxCnt, ulFindMax); 783 } 784 } 785 #endif // fixme to be gone 777 786 778 787 if (stopflag && *stopflag) 779 788 goto Abort; 780 p Byte = (PBYTE)paffbFound;781 for (x = 0; x < ulFileCnt;) {782 pffbFile = (PFILEFINDBUF4) pByte;789 pffbFile = paffbFound; 790 ulSelCnt = 0; 791 for (;;) { 783 792 if (!*pffbFile->achName || 784 (!filestoo && !(pffbFile->attrFile & FILE_DIRECTORY)) ||785 ( (pffbFile->attrFile & FILE_DIRECTORY)&&793 (!filestoo && ~pffbFile->attrFile & FILE_DIRECTORY) || 794 (pffbFile->attrFile & FILE_DIRECTORY && 786 795 pffbFile->achName[0] == '.' && 787 796 (!pffbFile->achName[1] || 788 797 (pffbFile->achName[1] == '.' && !pffbFile->achName[2])))) { 789 ulFileCnt--; // Got . or ..798 // ulFindCnt--; // Got . or .. or file to be skipped 790 799 } 791 800 else 792 papffbSelected[ x++] = pffbFile; // Countfile801 papffbSelected[ulSelCnt++] = pffbFile; // Remember selected file 793 802 if (!pffbFile->oNextEntryOffset) { 794 ulFileCnt = x; // Adjust count803 // ulFindCnt = ulSelCnt; // Remember number selected 795 804 break; 796 805 } 797 p Byte += pffbFile->oNextEntryOffset;806 pffbFile = (PFILEFINDBUF4)((PBYTE)pffbFile + pffbFile->oNextEntryOffset); 798 807 } // for 799 if (ulFileCnt) { 808 if (ulSelCnt) { 809 // One or more entries selected 800 810 if (stopflag && *stopflag) 801 811 goto Abort; 802 812 if (fSyncUpdates) { 803 813 pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD, 804 MPFROMLONG( ulExtraBytes),805 MPFROMLONG(ul FileCnt));814 MPFROMLONG(EXTRA_RECORD_BYTES), 815 MPFROMLONG(ulSelCnt)); 806 816 if (!pciFirst) { 807 817 Win_Error2(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, … … 811 821 } 812 822 else { 813 register INT i;814 815 823 pci = pciFirst; 816 824 ullTotalBytes = 0; 817 for (i = 0; i < ulFileCnt; i++) { 818 pffbFile = papffbSelected[i]; 825 // Insert selected in container 826 for (x = 0; x < ulSelCnt; x++) { 827 pffbFile = papffbSelected[x]; 819 828 ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec, 820 829 pffbFile, partial, dcd); … … 822 831 ullTotalBytes += ullBytes; 823 832 } // for 824 if (ulFileCnt) { 825 memset(&ri, 0, sizeof(RECORDINSERT)); 826 ri.cb = sizeof(RECORDINSERT); 827 ri.pRecordOrder = (PRECORDCORE) CMA_END; 828 ri.pRecordParent = (PRECORDCORE) pciParent; 829 ri.zOrder = (ULONG) CMA_TOP; 830 ri.cRecordsInsert = ulFileCnt; 831 ri.fInvalidateRecord = (!fSyncUpdates && dcd && 832 dcd->type == DIR_FRAME) ? 833 // 13 Aug 07 SHL ulSelCnt checked already? 834 // if (ulSelCnt) { 835 memset(&ri, 0, sizeof(RECORDINSERT)); 836 ri.cb = sizeof(RECORDINSERT); 837 ri.pRecordOrder = (PRECORDCORE) CMA_END; 838 ri.pRecordParent = (PRECORDCORE) pciParent; 839 ri.zOrder = (ULONG) CMA_TOP; 840 ri.cRecordsInsert = ulSelCnt; 841 ri.fInvalidateRecord = 842 !fSyncUpdates && dcd && dcd->type == DIR_FRAME ? 833 843 FALSE : TRUE; 844 if (!WinSendMsg(hwndCnr, 845 CM_INSERTRECORD, 846 MPFROMP(pciFirst), MPFROMP(&ri))) { 847 DosSleep(10); // Give GUI time to work 848 WinSetFocus(HWND_DESKTOP, hwndCnr); 834 849 if (!WinSendMsg(hwndCnr, 835 850 CM_INSERTRECORD, 836 851 MPFROMP(pciFirst), MPFROMP(&ri))) { 837 DosSleep(10); 838 WinSetFocus(HWND_DESKTOP, hwndCnr); 839 if (!WinSendMsg(hwndCnr, 840 CM_INSERTRECORD, 841 MPFROMP(pciFirst), MPFROMP(&ri))) { 842 Win_Error2(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, 843 IDS_CMINSERTERRTEXT); 844 ok = FALSE; 845 ullTotalBytes = 0; 846 if (WinIsWindow((HAB) 0, hwndCnr)) 847 FreeCnrItemList(hwndCnr, pciFirst); 848 } 852 Win_Error2(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, 853 IDS_CMINSERTERRTEXT); 854 ok = FALSE; 855 ullTotalBytes = 0; 856 if (WinIsWindow((HAB) 0, hwndCnr)) 857 FreeCnrItemList(hwndCnr, pciFirst); 849 858 } 859 // } 850 860 } 851 861 } 852 862 if (ok) { 853 863 ullReturnBytes += ullTotalBytes; 854 ulReturnFiles += ul FileCnt;864 ulReturnFiles += ulSelCnt; 855 865 } 856 } 866 } // if sync updates 857 867 else { 868 // Append newly selected entries to aggregate list 858 869 paffbTemp = xrealloc(paffbTotal, 859 sizeof(FILEFINDBUF4) * (ul FileCnt + ulTotal),870 sizeof(FILEFINDBUF4) * (ulSelCnt + ulTotal), 860 871 pszSrcFile, __LINE__); 861 872 if (paffbTemp) { 873 // 13 Aug 07 SHL fixme to optimize copy 862 874 paffbTotal = paffbTemp; 863 for (x = 0; x < ul FileCnt; x++)875 for (x = 0; x < ulSelCnt; x++) 864 876 paffbTotal[x + ulTotal] = *papffbSelected[x]; 865 ulTotal += ul FileCnt;877 ulTotal += ulSelCnt; 866 878 } 867 879 else { … … 872 884 } 873 885 } 874 } 886 } // if entries selected 875 887 if (stopflag && *stopflag) 876 888 goto Abort; 877 ulFileCnt = ulM;878 889 DosError(FERR_DISABLEHARDERR); 879 rc = DosFindNext(hdir, paffbFound, ulM * sizeof(FILEFINDBUF4),880 &ulFileCnt);890 ulFindCnt = ulFindMax; 891 rc = DosFindNext(hdir, paffbFound, ulBufBytes, &ulFindCnt); 881 892 priority_normal(); 882 893 if (rc) 883 894 DosError(FERR_DISABLEHARDERR); 884 } 895 } while (!rc); 896 885 897 DosFindClose(hdir); 886 898 887 if (paffbFound || papffbSelected) { 888 if (paffbFound) 889 free(paffbFound); 890 if (papffbSelected) 891 free(papffbSelected); 899 if (paffbFound) { 900 free(paffbFound); 901 paffbFound = NULL; 902 } 903 if (papffbSelected) { 904 free(papffbSelected); 892 905 papffbSelected = NULL; 893 paffbFound = NULL;894 906 } 895 907 … … 900 912 901 913 pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD, 902 MPFROMLONG( ulExtraBytes), MPFROMLONG(ulTotal));914 MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(ulTotal)); 903 915 if (!pciFirst) { 904 916 Win_Error2(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, … … 908 920 } 909 921 else { 910 register INT i;911 912 922 pci = pciFirst; 913 923 ullTotalBytes = 0; 914 pByte2 = (PBYTE) paffbTotal; 915 for (i = 0; i < ulTotal; i++) { 916 pffbFile = (PFILEFINDBUF4) pByte2; 924 pffbFile = paffbTotal; 925 for (x = 0; x < ulTotal; x++) { 917 926 ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec, 918 927 pffbFile, partial, dcd); 919 928 pci = (PCNRITEM) pci->rc.preccNextRecord; 920 929 ullTotalBytes += ullBytes; 921 922 p Byte2 += sizeof(FILEFINDBUF4);930 // Can not use offset since we have merged lists - this should be equivalent 931 pffbFile = (PFILEFINDBUF4)((PBYTE)pffbFile + sizeof(FILEFINDBUF4)); 923 932 } 924 933 if (ulTotal) { … … 933 942 if (!WinSendMsg(hwndCnr, CM_INSERTRECORD, 934 943 MPFROMP(pciFirst), MPFROMP(&ri))) { 935 DosSleep(10); 944 DosSleep(10); // Give GUI time to work 936 945 WinSetFocus(HWND_DESKTOP, hwndCnr); 937 946 if (!WinSendMsg(hwndCnr, CM_INSERTRECORD, … … 949 958 if (ok) { 950 959 ullReturnBytes += ullTotalBytes; 951 ulReturnFiles += ulFi leCnt;960 ulReturnFiles += ulFindCnt; 952 961 } 953 962 } 963 } 964 965 if (rc && rc != ERROR_NO_MORE_FILES) { 966 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 967 GetPString(IDS_CANTFINDDIRTEXT), pszFileSpec); 954 968 } 955 969 … … 959 973 } 960 974 Abort: 961 if (paffbTotal || papffbSelected || paffbFound || pszFileSpec) { 962 if (paffbTotal) 963 free(paffbTotal); 964 if (pszFileSpec) 965 free(pszFileSpec); 966 if (paffbFound) 967 free(paffbFound); 968 if (papffbSelected) 969 free(papffbSelected); 970 } 975 if (paffbTotal) 976 free(paffbTotal); 977 if (pszFileSpec) 978 free(pszFileSpec); 979 if (paffbFound) 980 free(paffbFound); 981 if (papffbSelected) 982 free(papffbSelected); 983 971 984 if (recurse) { 972 985 pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pciParent), … … 1231 1244 } 1232 1245 pci->rc.flRecordAttr |= CRA_RECORDREADONLY; 1233 pci = (PCNRITEM) pci->rc.preccNextRecord; / * next rec */1246 pci = (PCNRITEM) pci->rc.preccNextRecord; // next rec 1234 1247 } 1235 1248 else if (!(ulDriveMap & (1L << x))) … … 1240 1253 drivesbuilt = TRUE; 1241 1254 1242 / * insert the drives */1255 // insert the drives 1243 1256 if (numtoinsert && pciFirst) { 1244 1257 RECORDINSERT ri; … … 1259 1272 } 1260 1273 1261 / * move cursor onto the default drive rather than the first drive */1274 // move cursor onto the default drive rather than the first drive 1262 1275 if (!fSwitchTree) { 1263 1276 pci = (PCNRITEM) WinSendMsg(hwndCnr, … … 1446 1459 if (!drivesbuilt && hwndMain) 1447 1460 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID); 1448 DosSleep(16); //05 Aug 07 GKY 331461 DosSleep(16); // 05 Aug 07 GKY 33 1449 1462 fDummy = FALSE; 1450 1463 DosPostEventSem(CompactSem); … … 1583 1596 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, 1584 1597 "CM_FREERECORD hwnd %x pci %p file %s", 1585 hwnd, pci,1598 hwnd, pci, 1586 1599 pci && pci->pszFileName ? pci->pszFileName : "n/a"); 1587 1600 } … … 1664 1677 } 1665 1678 1679 #pragma alloc_text(FILLDIR,FillInRecordFromFFB,FillInRecordFromFSA,IDFile) 1680 #pragma alloc_text(FILLDIR1,ProcessDirectory,FillDirCnr,FillTreeCnr,FileAttrToString) 1681 #pragma alloc_text(EMPTYCNR,EmptyCnr,FreeCnrItemData,FreeCnrItem,FreeCnrItemList,RemoveCnrItems) 1682 -
trunk/dll/fm3res.dlg
r756 r783 28 28 19 Jun 07 SHL Update ABT_FRAME to include netlabs URL and built with OpenWatcom 29 29 03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading) 30 13 Aug 07 SHL Tweak scanning page 30 31 31 32 ***********************************************************************/ … … 1874 1875 AUTOCHECKBOX "Lowercase names", CFGS_FORCELOWER, 4, 68, 106, 10 1875 1876 AUTOCHECKBOX "Remote find bug", CFGS_REMOTEBUG, 4, 56, 106, 10 1876 AUTOCHECKBOX "Don't scan remov .", CFGS_NOREMOVABLESCAN, 4, 44,1877 AUTOCHECKBOX "Don't scan removables", CFGS_NOREMOVABLESCAN, 4, 44, 1877 1878 106, 10 1878 LTEXT "Find buf:", -1, 4, 28, 54, 12, NOT WS_GROUP1879 LTEXT "Find count", -1, 4, 28, 54, 12, NOT WS_GROUP 1879 1880 CONTROL "", CFGS_FILESTOGET, 44, 30, 64, 12, WC_SPINBUTTON, 1880 1881 SPBS_NUMERICONLY | SPBS_MASTER | SPBS_SERVANT | -
trunk/dll/grep.c
r775 r783 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2001, 200 6Steven H. Levine9 Copyright (c) 2001, 2007 Steven H. Levine 10 10 11 11 12 Feb 03 SHL insert_grepfile: standardize EA math … … 21 21 03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading) 22 22 06 Aug 07 GKY Reduce DosSleep times (ticket 148) 23 23 13 Aug 07 SHL Avoid pointer errors; sanitize code 24 13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat 24 25 25 26 ***********************************************************************/ … … 27 28 #define INCL_DOS 28 29 #define INCL_WIN 30 #define INCL_DOSERRORS 29 31 #define INCL_LONGLONG 30 32 #include <os2.h> … … 44 46 static PSZ pszSrcFile = __FILE__; 45 47 46 #pragma alloc_text(GREP,SecsSince1980,match,mmatch,GrepThread) 47 #pragma alloc_text(GREP,doallsubdirs,domatchingfiles) 48 49 /*****************************/ 50 /* Function Prototypes */ 51 /*****************************/ 52 53 static VOID doallsubdirs(GREP * grep, CHAR * searchPath, BOOL recursing, 48 static VOID doallsubdirs(GREP *grep, CHAR *searchPath, BOOL recursing, 54 49 char **fle, int numfls); 55 static INT domatchingfiles(GREP * grep, CHAR *path, char **fle, int numfls);56 static BOOL doonefile(GREP * grep, CHAR * fileName, FILEFINDBUF4 * f);57 static BOOL doinsertion(GREP * grep);58 static BOOL InsertDupe(GREP * grep, CHAR * dir, FILEFINDBUF4 * f);59 static VOID FillDupes(GREP * g);60 static VOID FreeDupes(GREP * g);50 static INT domatchingfiles(GREP *grep, CHAR *path, char **fle, int numfls); 51 static BOOL doonefile(GREP *grep, CHAR *fileName, FILEFINDBUF4 *pffb); 52 static BOOL doinsertion(GREP *grep); 53 static BOOL InsertDupe(GREP *grep, CHAR *dir, FILEFINDBUF4 *pffb); 54 static VOID FillDupes(GREP *grep); 55 static VOID FreeDupes(GREP *grep); 61 56 62 57 #define GREPCHARS "*?[] \\" 63 58 64 59 #define isleap(year) ((((year%4)==0) && ((year%100)!=0)) || \ 65 ((year%400)==0))60 ((year%400)==0)) 66 61 67 62 static INT monthdays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; … … 99 94 LONG len) 100 95 { 101 102 /* return TRUE if pattern found in string */ 103 96 // return TRUE if pattern found in string 104 97 register CHAR *tn = pattern; 105 98 register LONG len2 = 0; … … 108 101 109 102 if (len && string && pattern) { 110 if (absolute) / * no pattern matching */103 if (absolute) // no pattern matching 111 104 return (findstring(pattern, strlen(pattern), string, len, 112 105 (ignore == FALSE)) != NULL); … … 180 173 if (!*tn) 181 174 return FALSE; 182 / * else intentional fallthru */175 // else intentional fallthru 183 176 default: 184 177 if (ignore) { … … 217 210 LONG len, ULONG numlines, CHAR * matched, BOOL matchall) 218 211 { 219 220 212 BOOL ret = FALSE; 221 213 register CHAR *p; … … 229 221 if (matched && ret && x < numlines) 230 222 matched[x] = 1; 231 p += strlen(p); / * check each pattern in 0-terminated list */223 p += strlen(p); // check each pattern in 0-terminated list 232 224 p++; 233 225 x++; … … 245 237 CHAR *p, *pp, searchPath[CCHMAXPATH * 2]; 246 238 247 if (!arg) 239 if (!arg) { 240 Runtime_Error(pszSrcFile, __LINE__, "no data"); 248 241 return; 249 grep = *(GREP *) arg; 250 *grep.stopflag = 0; /* reset thread-killing flag */ 242 } 243 244 grep = *(GREP *)arg; 245 *grep.stopflag = 0; // reset thread-killing flag 251 246 grep.FilesToGet = FilesToGet; 252 247 DosError(FERR_DISABLEHARDERR); … … 268 263 while (*pp) { 269 264 if (!grep.absFlag) { 270 p = GREPCHARS; / * see if any sense in pattern matching */265 p = GREPCHARS; // see if any sense in pattern matching 271 266 while (*p) { 272 267 if (strchr(pp, *p)) … … 274 269 p++; 275 270 } 276 if (!*p) / * nope, turn it off */271 if (!*p) // nope, turn it off 277 272 grep.absFlag = TRUE; 278 273 } … … 300 295 } 301 296 302 while (x < numfls) { / * loop through search masks */303 304 if (*fle[x] == '/') / * is an exclude mask only */297 while (x < numfls) { // loop through search masks 298 299 if (*fle[x] == '/') // is an exclude mask only 305 300 goto ExcludeSkip; 306 301 307 / * first, separate any path from mask */302 // first, separate any path from mask 308 303 309 304 p = (char *)(fle[x] + (strlen(fle[x]) - 1)); … … 311 306 --p; 312 307 313 if (p == fle[x]) { / * no path */308 if (p == fle[x]) { // no path 314 309 strcpy(searchPath, grep.curdir); 315 310 strncpy(grep.fileMask, fle[x], CCHMAXPATH); 316 311 grep.fileMask[CCHMAXPATH - 1] = 0; 317 312 } 318 else { / * got to deal with a path */319 if (*p == ':') { / * just a drive, start in root dir */313 else { // got to deal with a path 314 if (*p == ':') { // just a drive, start in root dir 320 315 *p = 0; 321 316 p++; … … 325 320 strcpy(grep.fileMask, p); 326 321 } 327 if (*p == '\\') { / * got a 'full' path */322 if (*p == '\\') { // got a 'full' path 328 323 329 324 CHAR temp; … … 342 337 if (*grep.stopflag) 343 338 break; 344 / * do single directory */339 // do single directory 345 340 domatchingfiles(&grep, searchPath, fle, numfls); 346 if (grep.dirFlag) / * do subdirs */341 if (grep.dirFlag) // do subdirs 347 342 doallsubdirs(&grep, searchPath, FALSE, fle, numfls); 348 343 ExcludeSkip: … … 351 346 x++; 352 347 if (WinIsWindow(grep.ghab, grep.hwndFiles)) 353 doinsertion(&grep); / * insert any remaining objects */348 doinsertion(&grep); // insert any remaining objects 354 349 } // while 355 350 356 351 if (WinIsWindow(grep.ghab, grep.hwndFiles)) 357 doinsertion(&grep); / * insert any remaining objects */352 doinsertion(&grep); // insert any remaining objects 358 353 359 354 if (WinIsWindow(grep.ghab, grep.hwndFiles) && grep.finddupes && … … 361 356 FillDupes(&grep); 362 357 363 if (!PostMsg(grep.hwndFiles, UM_CONTAINER_FILLED, MPVOID, MPVOID)) / * tell window we're done */358 if (!PostMsg(grep.hwndFiles, UM_CONTAINER_FILLED, MPVOID, MPVOID)) // tell window we're done 364 359 WinSendMsg(grep.hwndFiles, UM_CONTAINER_FILLED, MPVOID, MPVOID); 365 360 WinDestroyMsgQueue(ghmq); … … 379 374 static BOOL IsExcluded(char *name, char **fle, int numfls) 380 375 { 381 registerint x;376 int x; 382 377 char *n; 383 378 … … 401 396 char **fle, int numfls) 402 397 { 403 404 /* process all subdirectories */ 405 406 FILEFINDBUF4 findBuffer; 398 // process all subdirectories 399 400 FILEFINDBUF4 ffb; 407 401 HDIR findHandle = HDIR_CREATE; 408 LONG findCount = 1L;402 LONG ulFindCnt = 1; 409 403 CHAR *p = NULL; 410 404 411 / * add a mask to search path */405 // add a mask to search path 412 406 if (searchPath[strlen(searchPath) - 1] != '\\') 413 407 strcat(searchPath, "\\"); 414 408 strcat(searchPath, "*"); 415 / * step through all subdirectories */409 // step through all subdirectories 416 410 DosError(FERR_DISABLEHARDERR); 417 411 if (!DosFindFirst(searchPath, &findHandle, (MUST_HAVE_DIRECTORY | 418 412 FILE_ARCHIVED | FILE_SYSTEM | 419 413 FILE_HIDDEN | FILE_READONLY), 420 &f indBuffer, (ULONG) sizeof(findBuffer),421 (PULONG) & findCount, FIL_QUERYEASIZE)) {422 423 / * get rid of mask portion, save end-of-directory */414 &ffb, (ULONG) sizeof(ffb), 415 (PULONG) & ulFindCnt, FIL_QUERYEASIZE)) { 416 417 // get rid of mask portion, save end-of-directory 424 418 425 419 p = strrchr(searchPath, '\\'); … … 428 422 else 429 423 p = searchPath; 430 do { / * Process each directory that matches the mask */424 do { // Process each directory that matches the mask 431 425 priority_normal(); 432 426 if (*grep->stopflag) 433 427 break; 434 428 // Skip . and .. 435 if (f indBuffer.achName[0] != '.' ||436 (f indBuffer.achName[1] &&437 (f indBuffer.achName[1] != '.' || findBuffer.achName[2]))) {438 strcpy(p, f indBuffer.achName);429 if (ffb.achName[0] != '.' || 430 (ffb.achName[1] && 431 (ffb.achName[1] != '.' || ffb.achName[2]))) { 432 strcpy(p, ffb.achName); 439 433 if (!grep->anyexcludes || !IsExcluded(searchPath, fle, numfls)) { 440 434 domatchingfiles(grep, searchPath, fle, numfls); … … 443 437 } 444 438 } 445 findCount = 1;439 ulFindCnt = 1; 446 440 } while (!DosFindNext(findHandle, 447 &f indBuffer,448 sizeof(f indBuffer), (PULONG) & findCount));441 &ffb, 442 sizeof(ffb), (PULONG) & ulFindCnt)); 449 443 DosFindClose(findHandle); 450 444 priority_normal(); 451 445 } 452 if (p) / * strip off last directory addition */446 if (p) // strip off last directory addition 453 447 *p = 0; 454 448 } … … 456 450 static INT domatchingfiles(GREP * grep, CHAR * path, char **fle, int numfls) 457 451 { 458 / * process all matching files in a directory */459 460 PFILEFINDBUF4 findBuffer;452 // process all matching files in a directory 453 454 PFILEFINDBUF4 pffbArray; 461 455 PFILEFINDBUF4 pffbFile; 462 register PBYTE fb; 463 register ULONG x; 456 ULONG x; 464 457 HDIR findHandle = HDIR_CREATE; 465 ULONG findCount = grep->FilesToGet; 466 CHAR newPath[CCHMAXPATH], *p; 458 ULONG ulFindCnt; 459 CHAR szFindPath[CCHMAXPATH]; 460 PSZ p; 467 461 APIRET rc; 468 469 findBuffer = 470 xmalloc(grep->FilesToGet * sizeof(FILEFINDBUF4), pszSrcFile, __LINE__);471 if (! findBuffer)462 ULONG ulBufBytes = grep->FilesToGet * sizeof(FILEFINDBUF4); 463 464 pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__); 465 if (!pffbArray) 472 466 return 0; 473 467 474 / * build filemask */475 476 sprintf(newPath,477 "%s%s%s",478 path,479 (path[strlen(path) - 1] == '\\') ? NullStr : "\\", grep->fileMask);480 481 MakeFullName( newPath);482 483 / * find and save end-of-dir position */484 p = strrchr( newPath, '\\');468 // build filemask 469 BldFullPathName(szFindPath, path, grep->fileMask); 470 // sprintf(szFindPath, 471 // "%s%s%s", 472 // path, 473 // (path[strlen(path) - 1] == '\\') ? NullStr : "\\", grep->fileMask); 474 475 MakeFullName(szFindPath); 476 477 // find and save end-of-dir position 478 p = strrchr(szFindPath, '\\'); 485 479 if (p) 486 480 p++; 487 481 else 488 p = newPath;489 490 / * step through matching files */482 p = szFindPath; 483 484 // step through matching files 491 485 DosError(FERR_DISABLEHARDERR); 492 if (!DosFindFirst(newPath, 486 ulFindCnt = grep->FilesToGet; 487 rc = DosFindFirst(szFindPath, 493 488 &findHandle, 494 (FILE_NORMAL | grep->attrFile | grep->antiattr), 495 findBuffer, 496 (ULONG) (grep->FilesToGet * sizeof(FILEFINDBUF4)), 497 (PULONG) & findCount, FIL_QUERYEASIZE)) { 498 499 do { /* Process each file that matches the mask */ 489 FILE_NORMAL | grep->attrFile | grep->antiattr, 490 pffbArray, 491 ulBufBytes, 492 &ulFindCnt, 493 FIL_QUERYEASIZE); 494 if (!rc) { 495 do { 496 // Process each file that matches the mask 500 497 priority_normal(); 501 fb = (PBYTE) findBuffer; 502 for (x = 0L; x < findCount; x++) { 503 pffbFile = (PFILEFINDBUF4) fb; 498 pffbFile = pffbArray; 499 for (x = 0; x < ulFindCnt; x++) { 504 500 if (*grep->stopflag) 505 501 break; 506 502 if (*pffbFile->achName != '.' || 507 503 (pffbFile->achName[1] && pffbFile->achName[1] != '.')) { 508 strcpy(p, pffbFile->achName); / * build filename */509 if (!grep->anyexcludes || !IsExcluded( newPath, fle, numfls)) {504 strcpy(p, pffbFile->achName); // build filename 505 if (!grep->anyexcludes || !IsExcluded(szFindPath, fle, numfls)) { 510 506 if (!grep->finddupes) 511 doonefile(grep, newPath, pffbFile);512 else if (!InsertDupe(grep, newPath, pffbFile)) {507 doonefile(grep, szFindPath, pffbFile); 508 else if (!InsertDupe(grep, szFindPath, pffbFile)) { 513 509 DosFindClose(findHandle); 514 free( findBuffer);510 free(pffbArray); 515 511 return 1; 516 512 } … … 519 515 if (!pffbFile->oNextEntryOffset) 520 516 break; 521 fb += pffbFile->oNextEntryOffset; 522 } 523 findCount = grep->FilesToGet; 524 rc = DosFindNext(findHandle, 525 findBuffer, 526 (ULONG) (grep->FilesToGet * sizeof(FILEFINDBUF4)), 527 (PULONG) & findCount); 528 if (!rc) 529 DosSleep(1); 517 pffbFile = (PFILEFINDBUF4)((PBYTE)pffbFile + pffbFile->oNextEntryOffset); 518 } // for 519 if (*grep->stopflag) 520 break; 521 DosSleep(1); 522 ulFindCnt = grep->FilesToGet; 523 rc = DosFindNext(findHandle, pffbArray, ulBufBytes, &ulFindCnt); 530 524 } while (!rc); 525 531 526 DosFindClose(findHandle); 532 527 priority_normal(); 533 } 534 free(findBuffer); 528 } // if 529 530 if (rc && rc != ERROR_NO_MORE_FILES) { 531 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 532 GetPString(IDS_CANTFINDDIRTEXT), szFindPath); 533 } 534 535 free(pffbArray); 535 536 return 0; 536 537 } 537 538 538 #pragma alloc_text(GREP,insert_grepfile,doonefile,doinsertion,freegreplist)539 540 539 static VOID freegreplist(GREP * grep) 541 540 { 542 registerINT x;541 INT x; 543 542 544 543 if (grep) { … … 607 606 } 608 607 609 static BOOL insert_grepfile(GREP * grep, CHAR * filename, FILEFINDBUF4 * f) 610 { 611 CHAR *p, szDirectory[CCHMAXPATH]; 608 static BOOL insert_grepfile(GREP *grep, CHAR *filename, PFILEFINDBUF4 pffb) 609 { 610 PSZ p; 611 CHAR szDirectory[CCHMAXPATH]; 612 612 613 613 if (WinIsWindow(grep->ghab, grep->hwndFiles)) { … … 620 620 *p = 0; 621 621 if (!grep->insertffb) { 622 grep->insertffb = xmallocz(sizeof(FILEFINDBUF4 *) * 623 (grep->FilesToGet + 1), pszSrcFile, 624 __LINE__); 622 // Allocate 1 extra for end marker? 623 grep->insertffb = 624 xmallocz(sizeof(PFILEFINDBUF4) * (grep->FilesToGet + 1), 625 pszSrcFile, __LINE__); 625 626 if (!grep->insertffb) 626 627 return FALSE; 627 628 grep->dir = 628 xmallocz(sizeof(CHAR *) * (grep->FilesToGet + 1), pszSrcFile,629 __LINE__);629 xmallocz(sizeof(CHAR *) * (grep->FilesToGet + 1), 630 pszSrcFile, __LINE__); 630 631 if (!grep->dir) { 631 632 free(grep->insertffb); … … 637 638 if (!grep->insertffb[grep->toinsert]) 638 639 return FALSE; 639 memcpy(grep->insertffb[grep->toinsert], f, sizeof(FILEFINDBUF4));640 memcpy(grep->insertffb[grep->toinsert], pffb, sizeof(FILEFINDBUF4)); 640 641 grep->dir[grep->toinsert] = xstrdup(szDirectory, pszSrcFile, __LINE__); 641 642 if (!grep->dir) { … … 643 644 return FALSE; 644 645 } 645 grep->insertedbytes += f->cbFile + CBLIST_TO_EASIZE(f->cbList);646 grep->insertedbytes += pffb->cbFile + CBLIST_TO_EASIZE(pffb->cbList); 646 647 grep->toinsert++; 647 648 if (grep->toinsert == grep->FilesToGet) … … 655 656 } 656 657 657 static BOOL doonefile(GREP * grep, CHAR * filename, FILEFINDBUF4 * f) 658 { 659 /* process a single file */ 660 658 static BOOL doonefile(GREP *grep, CHAR *filename, FILEFINDBUF4 * pffb) 659 { 660 // process a single file 661 661 CHAR *input; 662 662 FILE *inputFile; … … 673 673 ULONG adjsize; 674 674 675 adjsize = f->cbFile + (grep->searchEAs ? CBLIST_TO_EASIZE(f->cbList) : 0);675 adjsize = pffb->cbFile + (grep->searchEAs ? CBLIST_TO_EASIZE(pffb->cbList) : 0); 676 676 if (grep->greaterthan) { 677 677 if (adjsize < grep->greaterthan) … … 691 691 ULONG numsecs; 692 692 693 numsecs = SecsSince1980(& f->fdateLastWrite, &f->ftimeLastWrite);693 numsecs = SecsSince1980(&pffb->fdateLastWrite, &pffb->ftimeLastWrite); 694 694 if (grep->newerthan) { 695 695 if (numsecs < grep->newerthan) … … 704 704 } 705 705 706 if ((!grep->searchEAs && !grep->searchFiles) || !*grep->searchPattern) / * just a find */707 return insert_grepfile(grep, filename, f);706 if ((!grep->searchEAs && !grep->searchFiles) || !*grep->searchPattern) // just a find 707 return insert_grepfile(grep, filename, pffb); 708 708 709 709 if (grep->searchEAs) { … … 849 849 850 850 if (strmatch) 851 ret = insert_grepfile(grep, filename, f);851 ret = insert_grepfile(grep, filename, pffb); 852 852 return ret; 853 853 } 854 854 855 #pragma alloc_text(DUPES,InsertDupe,FillDupes,FreeDupes,CRCFile,CRCBlock) 856 #pragma alloc_text(DUPES,comparenamesq,comparenamesqe,comparenamesb) 857 #pragma alloc_text(DUPES,comparenamesbe,comparesizesq,comparesizesb) 858 859 static LONG cr3tab[] = { /* CRC polynomial 0xEDB88320 */ 855 static LONG cr3tab[] = { // CRC polynomial 0xEDB88320 860 856 861 857 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, … … 966 962 } 967 963 968 static VOID FreeDupes(GREP * g)964 static VOID FreeDupes(GREP *grep) 969 965 { 970 966 DUPES *i, *next; 971 967 972 i = g ->dupehead;968 i = grep->dupehead; 973 969 while (i) { 974 970 next = i->next; … … 978 974 i = next; 979 975 } 980 g ->dupehead = g->dupelast = NULL;981 if (g ->dupenames)982 free(g ->dupenames);983 if (g ->dupesizes)984 free(g ->dupesizes);985 g ->dupesizes = g->dupenames = NULL;976 grep->dupehead = grep->dupelast = NULL; 977 if (grep->dupenames) 978 free(grep->dupenames); 979 if (grep->dupesizes) 980 free(grep->dupesizes); 981 grep->dupesizes = grep->dupenames = NULL; 986 982 } 987 983 … … 1110 1106 } 1111 1107 1112 static VOID FillDupes(GREP * g )1108 static VOID FillDupes(GREP * grep) 1113 1109 { 1114 1110 DUPES *c, *i, **r; … … 1119 1115 ULONG cntr = 100; 1120 1116 1121 if (g ->CRCdupes)1117 if (grep->CRCdupes) 1122 1118 cntr = 50; 1123 i = g ->dupehead;1119 i = grep->dupehead; 1124 1120 while (i) { 1125 1121 x++; … … 1127 1123 } 1128 1124 if (x) { 1129 WinSetWindowText(g ->hwndCurFile, GetPString(IDS_GREPDUPESORTINGTEXT));1125 WinSetWindowText(grep->hwndCurFile, GetPString(IDS_GREPDUPESORTINGTEXT)); 1130 1126 DosSleep(1); 1131 g ->dupenames = xmalloc(sizeof(DUPES *) * (x + 1), pszSrcFile, __LINE__);1132 if (!g ->nosizedupes)1133 g ->dupesizes = xmalloc(sizeof(DUPES *) * (x + 1), pszSrcFile, __LINE__);1134 if (g ->dupenames && (g->nosizedupes || g->dupesizes)) {1135 i = g ->dupehead;1127 grep->dupenames = xmalloc(sizeof(DUPES *) * (x + 1), pszSrcFile, __LINE__); 1128 if (!grep->nosizedupes) 1129 grep->dupesizes = xmalloc(sizeof(DUPES *) * (x + 1), pszSrcFile, __LINE__); 1130 if (grep->dupenames && (grep->nosizedupes || grep->dupesizes)) { 1131 i = grep->dupehead; 1136 1132 while (i) { 1137 g ->dupenames[y] = i;1138 if (!g ->nosizedupes)1139 g ->dupesizes[y] = i;1133 grep->dupenames[y] = i; 1134 if (!grep->nosizedupes) 1135 grep->dupesizes[y] = i; 1140 1136 i = i->next; 1141 1137 y++; 1142 1138 } 1143 g ->dupenames[y] = NULL;1144 if (!g ->nosizedupes)1145 g ->dupesizes[y] = NULL;1139 grep->dupenames[y] = NULL; 1140 if (!grep->nosizedupes) 1141 grep->dupesizes[y] = NULL; 1146 1142 DosSleep(1); 1147 qsort(g ->dupenames,1143 qsort(grep->dupenames, 1148 1144 x, 1149 1145 sizeof(DUPES *), 1150 ((g ->ignoreextdupes) ? comparenamesqe : comparenamesq));1146 ((grep->ignoreextdupes) ? comparenamesqe : comparenamesq)); 1151 1147 DosSleep(1); 1152 if (!g ->nosizedupes) {1153 qsort(g ->dupesizes, x, sizeof(DUPES *), comparesizesq);1148 if (!grep->nosizedupes) { 1149 qsort(grep->dupesizes, x, sizeof(DUPES *), comparesizesq); 1154 1150 DosSleep(1); 1155 1151 } 1156 WinSetWindowText(g ->hwndCurFile, GetPString(IDS_GREPDUPECOMPARINGTEXT));1157 1158 i = g ->dupehead;1152 WinSetWindowText(grep->hwndCurFile, GetPString(IDS_GREPDUPECOMPARINGTEXT)); 1153 1154 i = grep->dupehead; 1159 1155 y = 0; 1160 1156 while (i) { 1161 if (*g ->stopflag)1157 if (*grep->stopflag) 1162 1158 break; 1163 1159 if (!(i->flags & GF_SKIPME)) { 1164 r = (DUPES **) bsearch(i, g ->dupenames, x, sizeof(DUPES *),1165 ((g ->ignoreextdupes) ? comparenamesbe :1160 r = (DUPES **) bsearch(i, grep->dupenames, x, sizeof(DUPES *), 1161 ((grep->ignoreextdupes) ? comparenamesbe : 1166 1162 comparenamesb)); 1167 1163 if (r) { 1168 while (r > g ->dupenames && ((g->ignoreextdupes) ?1164 while (r > grep->dupenames && ((grep->ignoreextdupes) ? 1169 1165 !comparenamesqe((r - 1), &i) : 1170 1166 !comparenamesq((r - 1), &i))) 1171 1167 r--; 1172 while (*r && ((g ->ignoreextdupes) ?1168 while (*r && ((grep->ignoreextdupes) ? 1173 1169 !comparenamesqe(r, &i) : !comparenamesq(r, &i))) { 1174 1170 if (*r == i || ((*r)->flags & (GF_INSERTED | GF_SKIPME))) { … … 1176 1172 continue; 1177 1173 } 1178 if (g ->CRCdupes) {1174 if (grep->CRCdupes) { 1179 1175 if ((*r)->CRC == -1L) { 1180 1176 (*r)->CRC = CRCFile((*r)->name, &error); … … 1200 1196 if (!AddToList((*r)->name, &list, &numfiles, &numalloced)) { 1201 1197 (*r)->flags |= GF_INSERTED; 1202 if (g ->sayfiles)1203 WinSetWindowText(g ->hwndFiles, (*r)->name);1198 if (grep->sayfiles) 1199 WinSetWindowText(grep->hwndFiles, (*r)->name); 1204 1200 if ((*r)->size == i->size && 1205 1201 (i->date.year == (*r)->date.year && … … 1221 1217 } 1222 1218 } 1223 if (!g ->nosizedupes) {1219 if (!grep->nosizedupes) { 1224 1220 r = (DUPES **) bsearch(i, 1225 g ->dupesizes,1221 grep->dupesizes, 1226 1222 x, sizeof(DUPES *), comparesizesb); 1227 1223 if (r) { 1228 while (r > g ->dupesizes && !comparesizesq((r - 1), &i))1224 while (r > grep->dupesizes && !comparesizesq((r - 1), &i)) 1229 1225 r--; 1230 1226 while (*r && !comparesizesq(r, &i)) { … … 1239 1235 continue; 1240 1236 } 1241 if (g ->CRCdupes) {1237 if (grep->CRCdupes) { 1242 1238 if ((*r)->CRC == -1L) { 1243 1239 (*r)->CRC = CRCFile((*r)->name, &error); … … 1261 1257 } 1262 1258 if (!AddToList((*r)->name, &list, &numfiles, &numalloced)) { 1263 if (g ->sayfiles)1264 WinSetWindowText(g ->hwndCurFile, (*r)->name);1259 if (grep->sayfiles) 1260 WinSetWindowText(grep->hwndCurFile, (*r)->name); 1265 1261 (*r)->flags |= GF_INSERTED; 1266 if (((g ->ignoreextdupes) ?1262 if (((grep->ignoreextdupes) ? 1267 1263 comparenamesqe(r, &i) : comparenamesq(r, &i))) 1268 1264 (*r)->flags |= GF_SKIPME; … … 1286 1282 CHAR s[44]; 1287 1283 1288 sprintf(s, GetPString(IDS_GREPDUPECHECKPROGTEXT), y, g ->numfiles);1289 WinSetWindowText(g ->hwndCurFile, s);1290 DosSleep(100); //05 Aug 07 GKY 1281284 sprintf(s, GetPString(IDS_GREPDUPECHECKPROGTEXT), y, grep->numfiles); 1285 WinSetWindowText(grep->hwndCurFile, s); 1286 DosSleep(100); //05 Aug 07 GKY 128 1291 1287 } 1292 1288 DosSleep(y % 2); … … 1296 1292 // Insufficient memory - fall back 1297 1293 DosBeep(50, 100); 1298 WinSetWindowText(g ->hwndCurFile, GetPString(IDS_GREPDUPECOMPARINGTEXT));1294 WinSetWindowText(grep->hwndCurFile, GetPString(IDS_GREPDUPECOMPARINGTEXT)); 1299 1295 x = y = 0; 1300 if (g ->dupenames) {1301 free(g ->dupenames);1302 g ->dupenames = NULL;1296 if (grep->dupenames) { 1297 free(grep->dupenames); 1298 grep->dupenames = NULL; 1303 1299 } 1304 if (g ->dupesizes) {1305 free(g ->dupesizes);1306 g ->dupesizes = NULL;1300 if (grep->dupesizes) { 1301 free(grep->dupesizes); 1302 grep->dupesizes = NULL; 1307 1303 } 1308 i = g ->dupehead;1304 i = grep->dupehead; 1309 1305 while (i) { 1310 if (*g ->stopflag)1306 if (*grep->stopflag) 1311 1307 break; 1312 1308 if (!(i->flags & GF_SKIPME)) { … … 1315 1311 CHAR s[44]; 1316 1312 1317 sprintf(s, GetPString(IDS_GREPDUPECHECKPROGTEXT), y, g ->numfiles);1318 WinSetWindowText(g ->hwndCurFile, s);1313 sprintf(s, GetPString(IDS_GREPDUPECHECKPROGTEXT), y, grep->numfiles); 1314 WinSetWindowText(grep->hwndCurFile, s); 1319 1315 DosSleep(1); 1320 1316 } … … 1325 1321 else 1326 1322 pi = i->name; 1327 c = g ->dupehead;1323 c = grep->dupehead; 1328 1324 while (c) { 1329 if (*g ->stopflag)1325 if (*grep->stopflag) 1330 1326 break; 1331 1327 if (c != i && !(c->flags & (GF_INSERTED | GF_SKIPME))) { … … 1336 1332 else 1337 1333 pc = c->name; 1338 if ((!g ->nosizedupes && i->size == c->size && i->date.year == c->date.year && i->date.month == c->date.month && i->date.day == c->date.day && i->time.hours == c->time.hours && i->time.minutes == c->time.minutes && i->time.twosecs == c->time.twosecs) || !stricmp(pc, pi)) { /* potential dupe */1339 if (g ->CRCdupes) {1340 if (g ->CRCdupes) {1334 if ((!grep->nosizedupes && i->size == c->size && i->date.year == c->date.year && i->date.month == c->date.month && i->date.day == c->date.day && i->time.hours == c->time.hours && i->time.minutes == c->time.minutes && i->time.twosecs == c->time.twosecs) || !stricmp(pc, pi)) { // potential dupe 1335 if (grep->CRCdupes) { 1336 if (grep->CRCdupes) { 1341 1337 if (c->CRC == -1L) { 1342 1338 c->CRC = CRCFile(c->name, &error); … … 1367 1363 goto BreakOut; // Failed 1368 1364 } 1369 if (g ->sayfiles)1370 WinSetWindowText(g ->hwndCurFile, pc);1365 if (grep->sayfiles) 1366 WinSetWindowText(grep->hwndCurFile, pc); 1371 1367 c->flags |= GF_INSERTED; 1372 1368 i->flags |= GF_INSERTED; … … 1387 1383 } 1388 1384 BreakOut: 1389 FreeDupes(g );1385 FreeDupes(grep); 1390 1386 if (numfiles && list) { 1391 if (!PostMsg(g ->hwndFiles,1387 if (!PostMsg(grep->hwndFiles, 1392 1388 WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list))) 1393 1389 FreeList(list); … … 1397 1393 } 1398 1394 1399 static BOOL InsertDupe(GREP * g, CHAR * dir, FILEFINDBUF4 * f)1395 static BOOL InsertDupe(GREP *grep, CHAR *dir, FILEFINDBUF4 *pffb) 1400 1396 { 1401 1397 DUPES *info; … … 1405 1401 if (!info) 1406 1402 return FALSE; 1407 else { 1408 info->name = xstrdup(dir, pszSrcFile, __LINE__); 1409 if (!info->name) { 1410 free(info); 1411 return FALSE; 1412 } 1413 else { 1414 info->size = f->cbFile; 1415 info->date = f->fdateLastWrite; 1416 info->time = f->ftimeLastWrite; 1417 info->CRC = -1L; 1418 g->numfiles++; 1419 if (!g->dupehead) 1420 g->dupehead = info; 1421 if (g->dupelast) 1422 g->dupelast->next = info; 1423 g->dupelast = info; 1424 info->next = NULL; 1425 } 1426 } 1403 1404 info->name = xstrdup(dir, pszSrcFile, __LINE__); 1405 if (!info->name) { 1406 free(info); 1407 return FALSE; 1408 } 1409 1410 info->size = pffb->cbFile; 1411 info->date = pffb->fdateLastWrite; 1412 info->time = pffb->ftimeLastWrite; 1413 info->CRC = -1L; 1414 grep->numfiles++; 1415 if (!grep->dupehead) 1416 grep->dupehead = info; 1417 if (grep->dupelast) 1418 grep->dupelast->next = info; 1419 grep->dupelast = info; 1420 info->next = NULL; 1427 1421 } 1428 1422 return TRUE; 1429 1423 } 1424 1425 #pragma alloc_text(GREP,insert_grepfile,doonefile,doinsertion,freegreplist) 1426 #pragma alloc_text(GREP,SecsSince1980,match,mmatch,GrepThread) 1427 #pragma alloc_text(GREP,doallsubdirs,domatchingfiles,InsertDupes,FreeDupes) 1428 1429 #pragma alloc_text(DUPES,InsertDupe,FillDupes,FreeDupes,CRCFile,CRCBlock) 1430 #pragma alloc_text(DUPES,comparenamesq,comparenamesqe,comparenamesb) 1431 #pragma alloc_text(DUPES,comparenamesbe,comparesizesq,comparesizesb) -
trunk/dll/init.c
r775 r783 28 28 03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading) 29 29 06 Aug 07 GKY Reduce DosSleep times (ticket 148) 30 30 13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat 31 31 32 32 ***********************************************************************/ … … 56 56 #include "version.h" 57 57 58 #ifdef __ WATCOMC__58 #ifdef __IBMC__ 59 59 #pragma alloc_text(INIT,LibMain,InitFM3DLL,DeInitFM3DLL) 60 #else // __IBMC__ 61 #pragma alloc_text(INIT,_DLL_InitTerm,InitFM3DLL,DeInitFM3DLL) 60 #pragma alloc_text(INIT1,StartFM3,FindSwapperDat) 62 61 #endif 63 64 #pragma alloc_text(INIT1,StartFM3,FindSwapperDat)65 62 66 63 extern int _CRT_init(void); … … 174 171 175 172 unsigned APIENTRY LibMain(unsigned hModule, 176 unsigned ulFlag)173 unsigned ulFlag) 177 174 { 178 175 CHAR *env; … … 1408 1405 return ok; 1409 1406 } 1407 1408 #ifdef __WATCOMC__ 1409 #pragma alloc_text(INIT,LibMain,InitFM3DLL,DeInitFM3DLL) 1410 #pragma alloc_text(INIT1,StartFM3,FindSwapperDat) 1411 #endif 1412 -
trunk/dll/ipf/notebook.ipf
r756 r783 6 6 .* 7 7 .* Copyright (c) 1993-98 M. Kimes 8 .* Copyright (c) 2006 -07 Steven H.Levine8 .* Copyright (c) 2006, 2007 Steven H.Levine 9 9 .* 10 10 .* 30 Dec 06 GKY Corrected statement re copy/move "toggle" in OS/2 11 11 .* 03 Mar 07 GKY Update that file systems other than HPFS support long names 12 .* 20 Mar 07 DG Add discribtion for Mommy make it stop 12 .* 20 Mar 07 DG Add description for Mommy make it stop 13 .* 13 Aug 07 SHL Tweak scanning page 13 14 .* 14 15 .*********************************************************************** … … 698 699 from the INI (which will cause FM/2 to revert to the default setting). 699 700 :p. 700 If the :hp6.Don't scan remov .:ehp6. is checked, FM/2 won't attempt to701 If the :hp6.Don't scan removables:ehp6. is checked, FM/2 won't attempt to 701 702 find subdirectories on removable drives until you double-click the drive 702 703 in the Drive Tree, so you won't see a [+] sign beside removable drives … … 707 708 loaded and scanned automatically at FM/2 startup. 708 709 :p. 709 The :hp6.Find buf:ehp6. spin button controls how many files FM/2 searches710 The :hp6.Find count:ehp6. spin button controls how many files FM/2 searches 710 711 for in one system call. The higher this number, the faster FM/2 works 711 712 (with properly operating FSDs that support "finding" more than one file … … 716 717 memory, boosting this may be a good idea. On the other hand, if you are 717 718 extremely limited in memory (less than 16 megs), reducing this might be 718 the thing to do. The range is 2048 to 102400, with 10240the default.719 the thing to do. The range is 512 to 4096, with 4096 being the default. 719 720 720 721 -
trunk/dll/notebook.c
r756 r783 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2004, 200 6Steven H. Levine9 Copyright (c) 2004, 2007 Steven H. Levine 10 10 11 11 01 Aug 04 SHL Rework lstrip/rstrip usage … … 16 16 15 Aug 06 SHL Rework SetMask args 17 17 03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading) 18 13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat 19 13 Aug 07 SHL Rework FileToGet min/max to match how DosFindFirst/Next works 18 20 19 21 ***********************************************************************/ … … 31 33 #include "fm3str.h" 32 34 35 #define FILESTOGET_MIN 256 36 #define FILESTOGET_MAX 4096 37 33 38 #pragma data_seg(DATA2) 34 39 35 40 static PSZ pszSrcFile = __FILE__; 36 37 #pragma alloc_text(NOTEBOOK,CfgTDlgProc,CfgTSDlgProc,CfgMDlgProc)38 #pragma alloc_text(NOTEBOOK2,CfgADlgProc,CfgSDlgProc,CfgVDlgProc)39 #pragma alloc_text(NOTEBOOK3,CfgDDlgProc,Cfg5DlgProc,Cfg6DlgProc)40 #pragma alloc_text(NOTEBOOK4,Cfg7DlgProc,Cfg8DlgProc,CfgCDlgProc)41 #pragma alloc_text(NOTEBOOK5,CfgGDlgProc,CfgDlgProc,CfgBDlgProc)42 41 43 42 typedef struct … … 226 225 MPFROMSHORT(8), MPVOID); 227 226 WinSendDlgItemMsg(hwnd, CFGS_FILESTOGET, SPBM_OVERRIDESETLIMITS, 228 MPFROMLONG(102400), MPFROMLONG(2048));227 MPFROMLONG(FILESTOGET_MAX), MPFROMLONG(FILESTOGET_MIN)); 229 228 PostMsg(hwnd, UM_UNDO, MPVOID, MPVOID); 230 229 break; … … 319 318 WinSendDlgItemMsg(hwnd, CFGS_FILESTOGET, SPBM_QUERYVALUE, 320 319 MPFROMP(&temp), MPFROM2SHORT(0, SPBQ_DONOTUPDATE)); 321 if (temp < 2048)322 temp = 2048;323 else if (temp > 102400)324 temp = 102400;320 if (temp < FILESTOGET_MIN) 321 temp = FILESTOGET_MIN; 322 else if (temp > FILESTOGET_MAX) 323 temp = FILESTOGET_MAX; 325 324 FilesToGet = temp; 326 325 PrfWriteProfileData(fmprof, … … 2184 2183 fVerify = FALSE; 2185 2184 DosSetVerify(FALSE); 2186 FilesToGet = 10240;2185 FilesToGet = FILESTOGET_MAX; 2187 2186 fQuickArcFind = TRUE; 2188 2187 fMinOnOpen = TRUE; … … 2235 2234 fQuickArcFind = TRUE; 2236 2235 fNoRemovableScan = TRUE; 2237 FilesToGet = 2048;2236 FilesToGet = FILESTOGET_MIN; 2238 2237 fFreeTree = FALSE; 2239 2238 fSplitStatus = TRUE; … … 2354 2353 fQuickArcFind = TRUE; 2355 2354 fNoRemovableScan = FALSE; 2356 FilesToGet = 10240;2355 FilesToGet = FILESTOGET_MAX; 2357 2356 fFreeTree = FALSE; 2358 2357 fSplitStatus = TRUE; … … 2930 2929 return WinDefDlgProc(hwnd, msg, mp1, mp2); 2931 2930 } 2931 2932 #pragma alloc_text(NOTEBOOK,CfgTDlgProc,CfgTSDlgProc,CfgMDlgProc) 2933 #pragma alloc_text(NOTEBOOK2,CfgADlgProc,CfgSDlgProc,CfgVDlgProc) 2934 #pragma alloc_text(NOTEBOOK3,CfgDDlgProc,Cfg5DlgProc,Cfg6DlgProc) 2935 #pragma alloc_text(NOTEBOOK4,Cfg7DlgProc,Cfg8DlgProc,CfgCDlgProc) 2936 #pragma alloc_text(NOTEBOOK5,CfgGDlgProc,CfgDlgProc,CfgBDlgProc) 2937 -
trunk/dll/objcnr.c
r775 r783 18 18 03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading) 19 19 06 Aug 07 GKY Reduce DosSleep times (ticket 148) 20 20 13 Aug 07 SHL Avoid realloc - not needed; sanitize code 21 13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat 21 22 22 23 ***********************************************************************/ … … 24 25 #define INCL_DOS 25 26 #define INCL_WIN 27 #define INCL_DOSERRORS 26 28 #include <os2.h> 27 29 … … 59 61 static HWND objcnrwnd; 60 62 61 #pragma alloc_text(OBJCNR,ProcessDir,FillCnrsThread,ObjCnrDlgProc) 62 63 static VOID ProcessDir(HWND hwndCnr, CHAR * filename,PCNRITEM pciParent,64 CHAR * stopflag)63 static VOID ProcessDir(HWND hwndCnr, 64 CHAR *filename, 65 PCNRITEM pciParent, 66 CHAR *stopflag) 65 67 { 66 68 CHAR maskstr[CCHMAXPATH], *endpath, *p; 67 ULONG nm, ulM; 69 ULONG ulFindCnt, ulFindMax; 70 ULONG ulBufBytes; 68 71 HDIR hdir; 69 FILEFINDBUF3 *ffb, *fft;72 PFILEFINDBUF3 pffbArray; 70 73 APIRET rc; 71 74 RECORDINSERT ri; 72 75 PCNRITEM pciP; 73 74 ffb = xmalloc(sizeof(FILEFINDBUF3), pszSrcFile, __LINE__); 75 if (!ffb) 76 return; 76 HPOINTER hptr; 77 78 ulBufBytes = sizeof(FILEFINDBUF3) * FilesToGet; 79 pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__); 80 if (!pffbArray) 81 return; // Error already reported 77 82 strcpy(maskstr, filename); 78 83 if (maskstr[strlen(maskstr) - 1] != '\\') … … 81 86 strcat(maskstr, "*"); 82 87 hdir = HDIR_CREATE; 83 nm= 1;88 ulFindCnt = 1; 84 89 rc = DosFindFirst(filename, &hdir, 85 90 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | 86 91 FILE_SYSTEM | FILE_HIDDEN | MUST_HAVE_DIRECTORY, 87 ffb, sizeof(FILEFINDBUF3), &nm, FIL_STANDARD);92 pffbArray, ulBufBytes, &ulFindCnt, FIL_STANDARD); 88 93 if (!rc) 89 94 DosFindClose(hdir); 90 91 if (rc) { /* work around furshluginer FAT bug... */ 92 if (IsRoot(filename)) 93 rc = 0; 94 } 95 96 if ((!rc && (ffb->attrFile & FILE_DIRECTORY))) { 95 // work around furshluginer FAT root bug 96 else if (IsRoot(filename)) 97 rc = 0; 98 99 if ((!rc && (pffbArray->attrFile & FILE_DIRECTORY))) { 97 100 pciP = WinSendMsg(hwndCnr, 98 101 CM_ALLOCRECORD, … … 100 103 MPFROMLONG(1)); 101 104 if (!pciP) { 102 free(ffb); 105 Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_ALLOCRECORD"); 106 free(pffbArray); 103 107 return; 104 108 } … … 125 129 } 126 130 else { 127 free(ffb); 128 Dos_Error(MB_ENTER, 129 rc, 130 HWND_DESKTOP, 131 pszSrcFile, 132 __LINE__, GetPString(IDS_CANTFINDDIRTEXT), filename); 131 free(pffbArray); 132 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 133 GetPString(IDS_CANTFINDDIRTEXT), filename); 133 134 return; 134 135 } 135 { 136 HPOINTER hptr; 137 138 hptr = WinLoadFileIcon(pciP->pszFileName, FALSE); 139 if (hptr) 140 pciP->rc.hptrIcon = hptr; 141 } 136 137 hptr = WinLoadFileIcon(pciP->pszFileName, FALSE); 138 if (hptr) 139 pciP->rc.hptrIcon = hptr; 140 142 141 if (!pciP->rc.hptrIcon || pciP->rc.hptrIcon == hptrFile) /* OS/2 bug bug bug bug */ 143 142 pciP->rc.hptrIcon = hptrDir; 143 144 144 memset(&ri, 0, sizeof(RECORDINSERT)); 145 145 ri.cb = sizeof(RECORDINSERT); … … 150 150 ri.fInvalidateRecord = TRUE; 151 151 if (!WinSendMsg(hwndCnr, CM_INSERTRECORD, MPFROMP(pciP), MPFROMP(&ri))) { 152 free( ffb);152 free(pffbArray); 153 153 return; 154 154 } … … 156 156 if (!isalpha(*maskstr) || maskstr[1] != ':' || maskstr[2] != '\\' || 157 157 ((driveflags[toupper(*maskstr) - 'A'] & DRIVE_REMOTE) && fRemoteBug)) 158 ul M= 1;158 ulFindMax = 1; 159 159 else 160 ulM = FilesToGet; 161 if (ulM > 1) { 162 fft = xrealloc(ffb, sizeof(FILEFINDBUF3) * ulM, pszSrcFile, __LINE__); 163 if (!fft) 164 ulM = 1; 165 else 166 ffb = fft; 167 } 168 nm = ulM; 160 ulFindMax = FilesToGet; 161 ulFindCnt = ulFindMax; 169 162 rc = DosFindFirst(maskstr, &hdir, 170 163 FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | 171 FILE_SYSTEM | FILE_HIDDEN | MUST_HAVE_DIRECTORY, ffb,172 sizeof(FILEFINDBUF3) * ulM, &nm, FIL_STANDARD);164 FILE_SYSTEM | FILE_HIDDEN | MUST_HAVE_DIRECTORY, 165 pffbArray, ulBufBytes, &ulFindCnt, FIL_STANDARD); 173 166 if (!rc) { 174 175 register PBYTE fb = (PBYTE) ffb; 176 FILEFINDBUF3 *pffbFile; 167 PFILEFINDBUF3 pffbFile; 177 168 ULONG x; 178 169 179 170 while (!rc) { 180 for (x = 0; x < nm; x++) {181 pffbFile = (FILEFINDBUF3 *) fb; 171 pffbFile = pffbArray; 172 for (x = 0; x < ulFindCnt; x++) { 182 173 if (*stopflag) 183 174 break; … … 192 183 if (!pffbFile->oNextEntryOffset) 193 184 break; 194 fb += pffbFile->oNextEntryOffset;195 } 185 pffbFile = (PFILEFINDBUF3)((PBYTE)pffbFile + pffbFile->oNextEntryOffset); 186 } // for 196 187 DosSleep(1); 197 188 if (*stopflag) 198 189 break; 199 nm = ulM;200 rc = DosFindNext(hdir, ffb, sizeof(FILEFINDBUF3) * ulM, &nm);201 } 190 ulFindCnt = ulFindMax; 191 rc = DosFindNext(hdir, pffbArray, ulBufBytes, &ulFindCnt); 192 } // while 202 193 DosFindClose(hdir); 203 194 } 204 free(ffb); 195 196 if (rc && rc != ERROR_NO_MORE_FILES) { 197 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 198 GetPString(IDS_CANTFINDDIRTEXT), filename); 199 } 200 201 free(pffbArray); 205 202 WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPFROMP(&pciP), 206 203 MPFROM2SHORT(1, 0)); … … 211 208 HAB hab; 212 209 HMQ hmq; 213 DIRSIZE *dirsize = (DIRSIZE *) args; 214 215 if (!dirsize) 210 DIRSIZE *dirsize = (DIRSIZE *)args; 211 212 if (!dirsize) { 213 Runtime_Error(pszSrcFile, __LINE__, "no data"); 216 214 return; 215 } 217 216 218 217 DosError(FERR_DISABLEHARDERR); … … 430 429 return WinDefDlgProc(hwnd, msg, mp1, mp2); 431 430 } 431 432 #pragma alloc_text(OBJCNR,ProcessDir,FillCnrsThread,ObjCnrDlgProc) -
trunk/dll/seeall.c
r775 r783 22 22 03 Nov 06 SHL Count thread usage 23 23 30 Mar 07 GKY Remove GetPString for window class names 24 03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading)24 03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speeds file loading) 25 25 06 Aug 07 GKY Reduce DosSleep times (ticket 148) 26 26 07 Aug 07 SHL Use BldQuotedFullPathName and BldQuotedFileName 27 13 Aug 07 SHL Sync code with other FilesToGet usage 28 13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat 27 29 28 30 ***********************************************************************/ … … 48 50 49 51 static PSZ pszSrcFile = __FILE__; 50 51 #pragma alloc_text(SEEALL,comparefullnames,comparenames,comparesizes)52 #pragma alloc_text(SEEALL,comparedates,compareexts,SeeStatusProc)53 #pragma alloc_text(SEEALL,InitWindow,PaintLine,SeeAllWndProc)54 #pragma alloc_text(SEEALL,UpdateList,CollectList,ReSort,Mark)55 #pragma alloc_text(SEEALL,BuildAList,RemoveDeleted,SeeFrameWndProc,FilterList)56 #pragma alloc_text(SEEALL2,SeeObjWndProc,MakeSeeObjWinThread,FindDupes,DupeDlgProc)57 #pragma alloc_text(SEEALL3,FreeAllFilesList,DoADir,FindAllThread,AFDrvsWndProc)58 #pragma alloc_text(SEEALL3,StartSeeAll)59 52 60 53 typedef struct … … 726 719 // Assume <2GB since file did not fit 727 720 clFreeBytes = fsa.cUnitAvail * fsa.cSectorUnit * 728 fsa.cbSector;721 fsa.cbSector; 729 722 if (clFreeBytes) { 730 723 // Find item that will fit in available space … … 1413 1406 } 1414 1407 1415 static BOOL UpdateList(HWND hwnd, CHAR ** list)1408 static BOOL UpdateList(HWND hwnd, CHAR **list) 1416 1409 { 1417 1410 /* Updates files in the list */ 1418 1411 1419 1412 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER); 1420 registerULONG x, z;1413 ULONG x, z; 1421 1414 BOOL ret, didone = FALSE; 1422 1415 FILEFINDBUF3 ffb; 1423 ULONG nm;1416 ULONG ulFindCnt; 1424 1417 HDIR hdir; 1425 1418 CHAR *p; … … 1437 1430 didone = TRUE; 1438 1431 hdir = HDIR_CREATE; 1439 nm= 1;1432 ulFindCnt = 1; 1440 1433 if (!DosFindFirst(list[z], &hdir, FILE_NORMAL | FILE_ARCHIVED | 1441 1434 FILE_DIRECTORY | FILE_READONLY | FILE_SYSTEM | 1442 FILE_HIDDEN, &ffb, sizeof(ffb), & nm,1435 FILE_HIDDEN, &ffb, sizeof(ffb), &ulFindCnt, 1443 1436 FIL_STANDARD)) { 1444 1437 DosFindClose(hdir); … … 1458 1451 didone = TRUE; 1459 1452 hdir = HDIR_CREATE; 1460 nm= 1;1453 ulFindCnt = 1; 1461 1454 if (!DosFindFirst(list[z], &hdir, FILE_NORMAL | FILE_ARCHIVED | 1462 1455 FILE_DIRECTORY | FILE_READONLY | FILE_SYSTEM | 1463 FILE_HIDDEN, &ffb, sizeof(ffb), & nm,1456 FILE_HIDDEN, &ffb, sizeof(ffb), &ulFindCnt, 1464 1457 FIL_STANDARD)) { 1465 1458 DosFindClose(hdir); … … 1893 1886 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER); 1894 1887 CHAR *filename, *enddir; 1895 FILEFINDBUF3 *pffb, *ffb;1888 PFILEFINDBUF3 pffbArray, pffbFile; 1896 1889 HDIR hdir = HDIR_CREATE; 1897 ULONG nm, uL; 1898 register ULONG x; 1899 register PBYTE fb; 1890 ULONG ulFindCnt; 1891 ULONG ulFindMax; 1892 ULONG ulBufBytes; 1893 ULONG x; 1894 APIRET rc; 1900 1895 1901 1896 filename = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__); … … 1903 1898 return; 1904 1899 1905 u L= ad->afFilesToGet;1900 ulFindMax = ad->afFilesToGet; 1906 1901 if (fRemoteBug && isalpha(*pathname) && pathname[1] == ':' && 1907 1902 pathname[2] == '\\' && 1908 1903 (driveflags[toupper(*pathname) - 'A'] & DRIVE_REMOTE)) 1909 uL = 1; 1910 pffb = xmalloc(sizeof(FILEFINDBUF3) * uL, pszSrcFile, __LINE__); 1911 if (!pffb) { 1904 ulFindMax = 1; 1905 1906 ulBufBytes = sizeof(FILEFINDBUF3) * ulFindMax; 1907 pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__); 1908 if (!pffbArray) { 1912 1909 free(filename); 1913 1910 return; 1914 1911 } 1915 nm = uL; 1912 1916 1913 strcpy(filename, pathname); 1917 1914 enddir = &filename[strlen(filename) - 1]; … … 1923 1920 strcpy(enddir, "*"); 1924 1921 DosError(FERR_DISABLEHARDERR); 1925 if (!DosFindFirst(filename, &hdir, FILE_NORMAL | FILE_ARCHIVED | 1922 ulFindCnt = ulFindMax; 1923 rc = DosFindFirst(filename, &hdir, FILE_NORMAL | FILE_ARCHIVED | 1926 1924 FILE_READONLY | FILE_DIRECTORY | FILE_SYSTEM | 1927 FILE_HIDDEN, pffb, sizeof(FILEFINDBUF3) * nm, &nm, 1928 FIL_STANDARD)) { 1925 FILE_HIDDEN, 1926 pffbArray, ulBufBytes, &ulFindCnt, FIL_STANDARD); 1927 if (!rc) { 1929 1928 do { 1929 #if 0 // 13 Aug 07 SHL fixme to be gone 1930 { 1931 static ULONG ulMaxCnt = 1; 1932 if (ulFindCnt > ulMaxCnt) { 1933 ulMaxCnt = ulFindCnt; 1934 DbgMsg(pszSrcFile, __LINE__, "ulMaxCnt %u/%u", ulMaxCnt, ulFindMax); 1935 } 1936 } 1937 #endif // fixme to be gone 1930 1938 priority_normal(); 1931 fb = (PBYTE) pffb; 1932 for (x = 0; x < nm; x++) { 1933 ffb = (FILEFINDBUF3 *) fb; 1934 if (ffb->attrFile & FILE_DIRECTORY) { 1939 pffbFile = pffbArray; 1940 for (x = 0; x < ulFindCnt; x++) { 1941 if (pffbFile->attrFile & FILE_DIRECTORY) { 1935 1942 // Skip . and .. 1936 if ( ffb->achName[0] != '.' ||1937 ( ffb->achName[1] &&1938 ( ffb->achName[1] != '.' || ffb->achName[2]))) {1939 strcpy(enddir, ffb->achName);1943 if (pffbFile->achName[0] != '.' || 1944 (pffbFile->achName[1] && 1945 (pffbFile->achName[1] != '.' || pffbFile->achName[2]))) { 1946 strcpy(enddir, pffbFile->achName); 1940 1947 DoADir(hwnd, filename); 1941 1948 } … … 1943 1950 else { 1944 1951 *enddir = 0; 1945 strcpy(enddir, ffb->achName);1952 strcpy(enddir, pffbFile->achName); 1946 1953 if (!ad->afalloc || ad->affiles > ad->afalloc - 1) { 1947 1954 … … 1970 1977 ad->afhead[ad->affiles].filename = 1971 1978 ad->afhead[ad->affiles].fullname + (enddir - filename); 1972 ad->afhead[ad->affiles].cbFile = ffb->cbFile;1973 ad->afhead[ad->affiles].date = ffb->fdateLastWrite;1974 ad->afhead[ad->affiles].time = ffb->ftimeLastWrite;1975 ad->afhead[ad->affiles].attrFile = (USHORT) ffb->attrFile;1979 ad->afhead[ad->affiles].cbFile = pffbFile->cbFile; 1980 ad->afhead[ad->affiles].date = pffbFile->fdateLastWrite; 1981 ad->afhead[ad->affiles].time = pffbFile->ftimeLastWrite; 1982 ad->afhead[ad->affiles].attrFile = (USHORT) pffbFile->attrFile; 1976 1983 ad->afhead[ad->affiles].flags = 0; 1977 1984 ad->affiles++; 1978 if (ad->longest < ffb->cchName) 1979 ad->longest = ffb->cchName; 1980 if (ad->longestw < ffb->cchName + (enddir - filename)) 1981 ad->longestw = ffb->cchName + (enddir - filename); 1982 } 1983 } 1984 fb += ffb->oNextEntryOffset; 1985 } 1986 nm = uL; 1987 } while (!ad->stopflag && 1988 !DosFindNext(hdir, pffb, sizeof(FILEFINDBUF3) * nm, &nm)); 1985 if (ad->longest < pffbFile->cchName) 1986 ad->longest = pffbFile->cchName; 1987 if (ad->longestw < pffbFile->cchName + (enddir - filename)) 1988 ad->longestw = pffbFile->cchName + (enddir - filename); 1989 } 1990 } 1991 pffbFile = (PFILEFINDBUF3)((PBYTE)pffbFile + pffbFile->oNextEntryOffset); 1992 } // for 1993 if (ad->stopflag) 1994 break; 1995 ulFindCnt = ulFindMax; 1996 rc = DosFindNext(hdir, pffbArray, sizeof(FILEFINDBUF3) * ulFindCnt, &ulFindCnt); 1997 } while (!rc); 1989 1998 DosFindClose(hdir); 1990 1999 } 1991 free(pffb); 2000 2001 if (rc && rc != ERROR_NO_MORE_FILES) { 2002 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 2003 GetPString(IDS_CANTFINDDIRTEXT), filename); 2004 } 2005 2006 free(pffbArray); 1992 2007 free(filename); 1993 2008 } … … 2216 2231 RECTL * Rectl) 2217 2232 { 2218 2219 2233 ALLDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER); 2220 2234 POINTL ptl; … … 3802 3816 3803 3817 case WM_COMMAND: 3804 if (!pAD) 3818 if (!pAD) { 3819 Runtime_Error(pszSrcFile, __LINE__, "no data"); 3805 3820 return 0; 3821 } 3806 3822 switch (SHORT1FROMMP(mp1)) { 3807 3823 case IDM_SETTARGET: … … 4272 4288 return hwndFrame; 4273 4289 } 4290 4291 #pragma alloc_text(SEEALL,comparefullnames,comparenames,comparesizes) 4292 #pragma alloc_text(SEEALL,comparedates,compareexts,SeeStatusProc) 4293 #pragma alloc_text(SEEALL,InitWindow,PaintLine,SeeAllWndProc) 4294 #pragma alloc_text(SEEALL,UpdateList,CollectList,ReSort,Mark) 4295 #pragma alloc_text(SEEALL,BuildAList,RemoveDeleted,SeeFrameWndProc,FilterList) 4296 #pragma alloc_text(SEEALL2,SeeObjWndProc,MakeSeeObjWinThread,FindDupes,DupeDlgProc) 4297 #pragma alloc_text(SEEALL3,FreeAllFilesList,DoADir,FindAllThread,AFDrvsWndProc) 4298 #pragma alloc_text(SEEALL3,StartSeeAll) 4299
Note:
See TracChangeset
for help on using the changeset viewer.
