Changeset 1892 for trunk/dll/filldir.c
- Timestamp:
- Jan 31, 2020, 6:45:23 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/filldir.c
r1891 r1892 125 125 26 Sep 15 GKY Remove fInitialDriveScan code 126 126 28 Jan 20 SHL EmptyCnr: report more errors 127 29 Jan 20 SHL RemoveCnrItems: rework removal from prev/next chain 127 29 Jan 20 SHL Rework RemoveCnrItems removal to not use prev/next chain 128 30 Jan 20 SHL Rework RemoveCnrItems to avoid possible traps on bad input 129 30 Jan 20 SHL Clean up some inconsistent formatting 128 130 129 131 ***********************************************************************/ … … 297 299 hptr = hptrArt; 298 300 else 299 hptr = (HPOINTER) 301 hptr = (HPOINTER)0; 300 302 } 301 303 else 302 hptr = (HPOINTER) 304 hptr = (HPOINTER)0; 303 305 304 306 return hptr; … … 319 321 320 322 // try to guess WPS default file icon 321 hptr2 = (HPOINTER) 323 hptr2 = (HPOINTER)0; 322 324 for (u = 0; !hptrWPSFile && u < 10; u++) { 323 325 char szFileName[CCHMAXPATH]; … … 367 369 ULONG flags = driveflags[toupper(*pci->pszFileName) - 'A']; 368 370 BOOL fLoadSubjectForDrive = fLoadSubject && ~flags & DRIVE_NOLOADSUBJS; 369 BOOL fLoadLongNameForDrive = fLoadLongnames && 371 BOOL fLoadLongNameForDrive = fLoadLongnames && // ~flags & DRIVE_NOLONGNAMES && 370 372 ~flags & DRIVE_NOLOADLONGS; 371 373 if (fLoadSubjectForDrive || fLoadLongNameForDrive) { … … 411 413 eaop.fpFEA2List = pfealist; 412 414 eaop.oError = 0; 413 rc = DosQueryPathInfo(pci->pszFileName, FIL_QUERYEASFROMLIST, 414 (PVOID) &eaop, (ULONG) sizeof(EAOP2)); 415 rc = DosQueryPathInfo(pci->pszFileName, 416 FIL_QUERYEASFROMLIST, 417 (PVOID)&eaop, 418 (ULONG)sizeof(EAOP2)); 415 419 // Prevent this error from occuring when scanning a directory 416 420 // that contains a locked data file … … 533 537 (flags & DRIVE_NOLOADICONS) || 534 538 !isalpha(*pci->pszFileName)) { 535 hptr = (HPOINTER) 539 hptr = (HPOINTER)0; 536 540 } 537 541 else … … 543 547 (flags & DRIVE_NOLOADICONS) || 544 548 !isalpha(*pci->pszFileName)) { 545 hptr = (HPOINTER) 549 hptr = (HPOINTER)0; 546 550 } 547 551 else … … 630 634 != (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)))) { 631 635 if (*dcd->mask.szMask || dcd->mask.antiattr) { 632 if (!Filter((PMINIRECORDCORE) pci, (PVOID) &dcd->mask))636 if (!Filter((PMINIRECORDCORE)pci, (PVOID)&dcd->mask)) 633 637 pci->rc.flRecordAttr |= CRA_FILTERED; 634 638 } … … 792 796 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)))) { 793 797 if (*dcd->mask.szMask || dcd->mask.antiattr) { 794 if (!Filter((PMINIRECORDCORE) pci, (PVOID) &dcd->mask))798 if (!Filter((PMINIRECORDCORE)pci, (PVOID)&dcd->mask)) 795 799 pci->rc.flRecordAttr |= CRA_FILTERED; 796 800 } … … 954 958 pffbFile, partial, dcd); 955 959 pciNext = pci; 956 pci = (PCNRITEM) 960 pci = (PCNRITEM)pci->rc.preccNextRecord; 957 961 ullTotalBytes += ullBytes; 958 962 } // for … … 960 964 memset(&ri, 0, sizeof(RECORDINSERT)); 961 965 ri.cb = sizeof(RECORDINSERT); 962 ri.pRecordOrder = (PRECORDCORE) 963 ri.pRecordParent = (PRECORDCORE) 964 ri.zOrder = (ULONG) 966 ri.pRecordOrder = (PRECORDCORE)CMA_END; 967 ri.pRecordParent = (PRECORDCORE)pciParent; 968 ri.zOrder = (ULONG)CMA_TOP; 965 969 ri.cRecordsInsert = ulSelCnt; 966 970 ri.fInvalidateRecord = TRUE; … … 978 982 ok = FALSE; 979 983 ullTotalBytes = 0; 980 if (WinIsWindow((HAB) 984 if (WinIsWindow((HAB)0, hwndCnr)) 981 985 FreeCnrItemList(hwndCnr, pciFirst); 982 986 } … … 1093 1097 ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec, 1094 1098 pffbFile, partial, dcd); 1095 pci = (PCNRITEM) 1099 pci = (PCNRITEM)pci->rc.preccNextRecord; 1096 1100 ullTotalBytes += ullBytes; 1097 1101 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); … … 1113 1117 memset(&ri, 0, sizeof(RECORDINSERT)); 1114 1118 ri.cb = sizeof(RECORDINSERT); 1115 ri.pRecordOrder = (PRECORDCORE) 1116 ri.pRecordParent = (PRECORDCORE) 1117 ri.zOrder = (ULONG) 1119 ri.pRecordOrder = (PRECORDCORE)CMA_END; 1120 ri.pRecordParent = (PRECORDCORE)pciParent; 1121 ri.zOrder = (ULONG)CMA_TOP; 1118 1122 ri.cRecordsInsert = ulRecsToInsert; 1119 1123 ri.fInvalidateRecord = (!fSyncUpdates && dcd && … … 1130 1134 ok = FALSE; 1131 1135 ullTotalBytes = 0; 1132 if (WinIsWindow((HAB) 1136 if (WinIsWindow((HAB)0, hwndCnr)) 1133 1137 FreeCnrItemList(hwndCnr, pciFirst); 1134 1138 pciFirst = NULL; … … 1271 1275 if (!DosQuerySysInfo(QSV_BOOT_DRIVE, 1272 1276 QSV_BOOT_DRIVE, 1273 (PVOID) 1274 (ULONG) 1277 (PVOID)&startdrive, 1278 (ULONG)sizeof(ULONG)) && 1275 1279 startdrive) 1276 1280 { … … 1306 1310 CM_ALLOCRECORD, 1307 1311 MPFROMLONG(EXTRA_RECORD_BYTES), 1308 MPFROMLONG((ULONG) 1312 MPFROMLONG((ULONG)numtoinsert)); 1309 1313 } 1310 1314 … … 1351 1355 CHAR Key[80]; 1352 1356 1353 sprintf(Key, "%c.VerifyOffChecked", (CHAR) 1357 sprintf(Key, "%c.VerifyOffChecked", (CHAR)(iDrvNum + 'A')); 1354 1358 fVerifyOffChecked[iDrvNum] = TRUE; 1355 1359 PrfWriteProfileData(fmprof, appname, Key, &fVerifyOffChecked[iDrvNum], sizeof(BOOL)); … … 1370 1374 rc = DosQueryPathInfo(szDrive, 1371 1375 FIL_QUERYEASIZEL, 1372 &fsa4, (ULONG) sizeof(FILESTATUS4L)); 1376 &fsa4, 1377 (ULONG)sizeof(FILESTATUS4L)); 1373 1378 if (rc == ERROR_BAD_NET_RESP) { 1374 1379 DosError(FERR_DISABLEHARDERR); 1375 1380 rc = DosQueryPathInfo(szDrive, 1376 1381 FIL_STANDARDL, 1377 &fsa4, (ULONG) sizeof(FILESTATUS4L)); 1382 &fsa4, 1383 (ULONG)sizeof(FILESTATUS4L)); 1378 1384 fsa4.cbList = 0; 1379 1385 } … … 1449 1455 } 1450 1456 pci->rc.flRecordAttr |= CRA_RECORDREADONLY; 1451 pci = (PCNRITEM) 1457 pci = (PCNRITEM)pci->rc.preccNextRecord; // next rec 1452 1458 } 1453 1459 else if (~ulDriveMap & ulDriveMapMask) … … 1482 1488 memset(&ri, 0, sizeof(RECORDINSERT)); 1483 1489 ri.cb = sizeof(RECORDINSERT); 1484 ri.pRecordOrder = (PRECORDCORE) 1485 ri.pRecordParent = (PRECORDCORE) 1486 ri.zOrder = (ULONG) 1490 ri.pRecordOrder = (PRECORDCORE)CMA_END; 1491 ri.pRecordParent = (PRECORDCORE)NULL; 1492 ri.zOrder = (ULONG)CMA_TOP; 1487 1493 ri.cRecordsInsert = numtoinsert; 1488 1494 ri.fInvalidateRecord = FALSE; … … 1496 1502 1497 1503 // move cursor onto the default drive rather than the first drive 1498 pci = (PCNRITEM) 1499 1500 1501 1504 pci = (PCNRITEM)WinSendMsg(hwndCnr, 1505 CM_QUERYRECORD, 1506 MPVOID, 1507 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 1502 1508 while (pci && (INT)pci != -1) { 1503 if ((ULONG) 1509 if ((ULONG)(toupper(*pci->pszFileName) - '@') == ulCurDriveNum) { 1504 1510 WinSendMsg(hwndCnr, 1505 1511 CM_SETRECORDEMPHASIS, … … 1507 1513 break; 1508 1514 } 1509 pci = (PCNRITEM) 1510 1511 1512 1515 pci = (PCNRITEM)WinSendMsg(hwndCnr, 1516 CM_QUERYRECORD, 1517 MPFROMP(pci), 1518 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 1513 1519 } 1514 1520 … … 1528 1534 memset(&ri, 0, sizeof(RECORDINSERT)); 1529 1535 ri.cb = sizeof(RECORDINSERT); 1530 ri.pRecordOrder = (PRECORDCORE) 1531 ri.pRecordParent = (PRECORDCORE) 1532 ri.zOrder = (ULONG) 1536 ri.pRecordOrder = (PRECORDCORE)CMA_END; 1537 ri.pRecordParent = (PRECORDCORE)NULL; 1538 ri.zOrder = (ULONG)CMA_TOP; 1533 1539 ri.cRecordsInsert = 1; 1534 1540 ri.fInvalidateRecord = FALSE; … … 1565 1571 memset(&ri, 0, sizeof(RECORDINSERT)); 1566 1572 ri.cb = sizeof(RECORDINSERT); 1567 ri.pRecordOrder = (PRECORDCORE) 1568 ri.pRecordParent = (PRECORDCORE) 1569 ri.zOrder = (ULONG) 1573 ri.pRecordOrder = (PRECORDCORE)CMA_END; 1574 ri.pRecordParent = (PRECORDCORE)pciParent; 1575 ri.zOrder = (ULONG)CMA_TOP; 1570 1576 ri.cRecordsInsert = 1; 1571 1577 ri.fInvalidateRecord = FALSE; … … 1591 1597 1592 1598 // Run Stubby on each hard drive to ensure expand/collapse buttons correct 1593 pci = (PCNRITEM) 1594 1595 1596 1599 pci = (PCNRITEM)WinSendMsg(hwndCnr, 1600 CM_QUERYRECORD, 1601 MPVOID, 1602 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 1597 1603 while (pci && (INT)pci != -1) { 1598 pciNext = (PCNRITEM) 1599 1600 1601 1604 pciNext = (PCNRITEM)WinSendMsg(hwndCnr, 1605 CM_QUERYRECORD, 1606 MPFROMP(pci), 1607 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 1602 1608 if (~pci->flags & RECFLAGS_ENV) { 1603 1609 iDrvNum = toupper(*pci->pszFileName) - 'A'; // 0..25 … … 1627 1633 1628 1634 // Fill in environment CNRITEMs, if any 1629 pci = (PCNRITEM) 1630 1631 1632 1635 pci = (PCNRITEM)WinSendMsg(hwndCnr, 1636 CM_QUERYRECORD, 1637 MPVOID, 1638 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 1633 1639 while (pci && (INT)pci != -1) { 1634 pciNext = (PCNRITEM) 1635 1636 1637 1640 pciNext = (PCNRITEM)WinSendMsg(hwndCnr, 1641 CM_QUERYRECORD, 1642 MPFROMP(pci), 1643 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 1638 1644 if (pci->flags & RECFLAGS_ENV) { 1639 1645 pci = (PCNRITEM) WinSendMsg(hwndCnr, … … 1645 1651 if (pci->flags & RECFLAGS_ENV) 1646 1652 AddFleshWorkRequest(hwndCnr, pci, eFleshEnv); 1647 pci = (PCNRITEM) 1648 1649 1650 1653 pci = (PCNRITEM)WinSendMsg(hwndCnr, 1654 CM_QUERYRECORD, 1655 MPFROMP(pci), 1656 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 1651 1657 } 1652 1658 break; 1653 1659 } 1654 pci = (PCNRITEM) 1655 1656 1657 1660 pci = (PCNRITEM)WinSendMsg(hwndCnr, 1661 CM_QUERYRECORD, 1662 MPFROMP(pci), 1663 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 1658 1664 } // while pci 1659 1665 … … 1763 1769 1764 1770 // Remove field info descriptors 1765 pfi = (PFIELDINFO) WinSendMsg(hwnd, CM_QUERYDETAILFIELDINFO, MPVOID, 1766 MPFROMSHORT(CMA_FIRST)); 1771 pfi = (PFIELDINFO)WinSendMsg(hwnd, 1772 CM_QUERYDETAILFIELDINFO, 1773 MPVOID, 1774 MPFROMSHORT(CMA_FIRST)); 1767 1775 if (pfi && 1768 1776 (INT)WinSendMsg(hwnd, CM_REMOVEDETAILFIELDINFO, MPVOID, … … 1955 1963 InitITimer(&itdSleep, 500); 1956 1964 for (usCount = 0; pci; usCount++) { 1957 pciNext = (PCNRITEM) 1965 pciNext = (PCNRITEM)pci->rc.preccNextRecord; 1958 1966 FreeCnrItemData(pci); 1959 1967 pci = pciNext; 1960 1968 if (!IdleIfNeeded(&itdSleep, 30)) { 1961 1969 for (usCount = usCount + 1; pci; usCount++) { 1962 pciNext = (PCNRITEM) 1970 pciNext = (PCNRITEM)pci->rc.preccNextRecord; 1963 1971 FreeCnrItemData(pci); 1964 1972 pci = pciNext; … … 1978 1986 /** 1979 1987 * Remove item(s) from container and free associated storage if requested 1980 * @param pciFirst points to firstitem to remove or NULL to remove all1988 * @param pciFirst points to specific item to remove or NULL to remove all 1981 1989 * @param usCnt is 0 to remove all or 1 to remove specific record 1982 1990 * @param usFlags for CM_REMOVERECORD … … 1997 2005 remaining = -1; 1998 2006 } 1999 elseif (!usFlags & CMA_FREE) {2007 if (!usFlags & CMA_FREE) { 2000 2008 Runtime_Error(pszSrcFile, __LINE__, "usFlags must have CMA_FREE set"); 2001 2009 remaining = -1; 2002 2010 } 2003 elseif (!pciFirst) {2011 if (!pciFirst) { 2004 2012 // Removing all - query first 2005 2013 pciFirst = (PCNRITEM)WinSendMsg(hwnd, CM_QUERYRECORD, MPVOID, … … 2021 2029 // 2020-01-28 SHL Rework to use CMA_NEXT - preccNextRecord method was never reliable 2022 2030 pci = pciFirst; 2023 while (pci && (INT)pci != -1 ) {2031 while (pci && (INT)pci != -1 && remaining > 0) { 2024 2032 FreeCnrItemData(pci); 2025 if ( remaining &&--remaining == 0)2026 break; // pci point to last CNRITEM to be deleted2033 if (--remaining == 0) 2034 break; 2027 2035 pci = WinSendMsg(hwnd, CM_QUERYRECORD, MPFROMP(pci), 2028 2036 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); … … 2043 2051 remaining = (INT)WinSendMsg(hwnd, CM_REMOVERECORD, MPFROMP(&pciFirst), MPFROM2SHORT(usCnt, usFlags)); 2044 2052 if (remaining == -1) 2045 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_REMOVERECORD hwnd %x pci %p cnt %u", hwnd, pciFirst, usCnt);2053 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_REMOVERECORD hwnd %x pciFirst %p cnt %u", hwnd, pciFirst, usCnt); 2046 2054 else if (usCnt == 0 && remaining != 0) 2047 2055 Runtime_Error(pszSrcFile, __LINE__, "%u records remain after CM_REMOVERECORD", remaining);
Note:
See TracChangeset
for help on using the changeset viewer.