Changeset 344 for trunk/dll/update.c
- Timestamp:
- Jul 26, 2006, 7:28:23 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/update.c
r204 r344 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2003, 200 5Steven H. Levine9 Copyright (c) 2003, 2006 Steven H. Levine 10 10 11 11 12 Feb 03 SHL Standardize EA math … … 14 14 25 May 05 SHL Rework for FillInRecordFromFFB 15 15 06 Jun 05 SHL Drop unused code 16 22 Jul 06 SHL Use wrappers 16 17 17 18 ***********************************************************************/ … … 29 30 30 31 #include "fm3dll.h" 32 33 static PSZ pszSrcFile = __FILE__; 31 34 32 35 #pragma alloc_text(UPDATECNR,UpdateCnrRecord,UpdateCnrList) … … 333 336 *ffb.achName = 0; 334 337 ullTotalBytes = FillInRecordFromFFB(hwndCnr, 335 pci,338 pci, 336 339 filename, 337 340 &ffb, … … 439 442 if(!dcd) 440 443 dcd = INSTDATA(hwndCnr); 441 if(!dcd) 444 if (!dcd) { 445 Runtime_Error(pszSrcFile, __LINE__, "no data"); 442 446 return ret; 443 if(!filename || !howmany || !filename[0]) 447 } 448 if (!filename || !howmany || !filename[0]) 444 449 return ret; 445 450 { … … 454 459 numremain = cnri.cRecords; 455 460 } 456 pciList = malloc(sizeof(PCNRITEM) * howmany); 457 for(x = 0;filename[x] && x < howmany;x++) { 458 if(IsFullName(filename[x])) { 459 if(driveflags[toupper(*filename[x]) - 'A'] & DRIVE_NOTWRITEABLE) 460 /* ignore non-writeable drives */ 461 continue; 462 } 463 hDir = HDIR_CREATE; 464 status = DosFindFirst(filename[x], 465 &hDir, 466 FILE_NORMAL | FILE_DIRECTORY | 467 FILE_ARCHIVED | FILE_READONLY | 468 FILE_HIDDEN | FILE_SYSTEM, 469 &ffb, 470 sizeof(ffb), 471 &nm, 472 FIL_QUERYEASIZE); 473 if(!status) { 474 /* file exists */ 475 DosFindClose(hDir); 476 // if(dcd->type == TREE_FRAME && !(ffb.attrFile & FILE_DIRECTORY)) 477 // continue; 478 if(dcd->type == DIR_FRAME && 479 *dcd->directory) { 480 481 CHAR *p,temp; 482 483 p = strrchr(filename[x],'\\'); 484 if(p) { 485 if(p < filename[x] + 3) 486 p++; 487 temp = *p; 488 *p = 0; 489 if(stricmp(filename[x],dcd->directory)) { 490 *p = temp; 491 continue; 492 } 493 *p = temp; 494 } 495 else 461 pciList = xmalloc(sizeof(PCNRITEM) * howmany,pszSrcFile,__LINE__); 462 if (pciList) { 463 for (x = 0;filename[x] && x < howmany;x++) { 464 if (IsFullName(filename[x])) { 465 if (driveflags[toupper(*filename[x]) - 'A'] & DRIVE_NOTWRITEABLE) 466 /* ignore non-writeable drives */ 496 467 continue; 497 468 } 498 ret = TRUE; 499 pci = FindCnrRecord(hwndCnr, 500 filename[x], 501 (PCNRITEM)NULL, 502 partial, 503 FALSE, 504 TRUE); 505 if (pci) 506 { 507 /* update record? */ 508 if ((!fForceUpper && !fForceLower && 509 strcmp(pci->szFileName,filename[x])) || 510 pci->cbFile != ffb.cbFile || pci->attrFile != ffb.attrFile || 511 pci->easize != CBLIST_TO_EASIZE(ffb.cbList) || 512 pci->date.day != ffb.fdateLastWrite.day || 513 pci->date.month != ffb.fdateLastWrite.month || 514 pci->date.year != ffb.fdateLastWrite.year + 1980 || 515 pci->time.seconds != ffb.ftimeLastWrite.twosecs * 2 || 516 pci->time.minutes != ffb.ftimeLastWrite.minutes || 517 pci->time.hours != ffb.ftimeLastWrite.hours || 518 pci->ladate.day != ffb.fdateLastAccess.day || 519 pci->ladate.month != ffb.fdateLastAccess.month || 520 pci->ladate.year != ffb.fdateLastAccess.year + 1980 || 521 pci->latime.seconds != ffb.ftimeLastAccess.twosecs * 2 || 522 pci->latime.minutes != ffb.ftimeLastAccess.minutes || 523 pci->latime.hours != ffb.ftimeLastAccess.hours) 524 { 525 /* changed; update */ 526 pciList[numlist++] = pci; 527 *ffb.achName = 0; 528 ffb.cchName = 0; 529 FillInRecordFromFFB(hwndCnr, 530 pci, 531 filename[x], 532 &ffb, 533 partial, 534 dcd); 535 if (IsRoot(pci->szFileName)) 469 hDir = HDIR_CREATE; 470 status = DosFindFirst(filename[x], 471 &hDir, 472 FILE_NORMAL | FILE_DIRECTORY | 473 FILE_ARCHIVED | FILE_READONLY | 474 FILE_HIDDEN | FILE_SYSTEM, 475 &ffb, 476 sizeof(ffb), 477 &nm, 478 FIL_QUERYEASIZE); 479 if(!status) { 480 /* file exists */ 481 DosFindClose(hDir); 482 // if(dcd->type == TREE_FRAME && !(ffb.attrFile & FILE_DIRECTORY)) 483 // continue; 484 if(dcd->type == DIR_FRAME && 485 *dcd->directory) { 486 487 CHAR *p,temp; 488 489 p = strrchr(filename[x],'\\'); 490 if(p) { 491 if(p < filename[x] + 3) 492 p++; 493 temp = *p; 494 *p = 0; 495 if(stricmp(filename[x],dcd->directory)) { 496 *p = temp; 497 continue; 498 } 499 *p = temp; 500 } 501 else 502 continue; 503 } 504 ret = TRUE; 505 pci = FindCnrRecord(hwndCnr, 506 filename[x], 507 (PCNRITEM)NULL, 508 partial, 509 FALSE, 510 TRUE); 511 if (pci) 512 { 513 /* update record? */ 514 if ((!fForceUpper && !fForceLower && 515 strcmp(pci->szFileName,filename[x])) || 516 pci->cbFile != ffb.cbFile || pci->attrFile != ffb.attrFile || 517 pci->easize != CBLIST_TO_EASIZE(ffb.cbList) || 518 pci->date.day != ffb.fdateLastWrite.day || 519 pci->date.month != ffb.fdateLastWrite.month || 520 pci->date.year != ffb.fdateLastWrite.year + 1980 || 521 pci->time.seconds != ffb.ftimeLastWrite.twosecs * 2 || 522 pci->time.minutes != ffb.ftimeLastWrite.minutes || 523 pci->time.hours != ffb.ftimeLastWrite.hours || 524 pci->ladate.day != ffb.fdateLastAccess.day || 525 pci->ladate.month != ffb.fdateLastAccess.month || 526 pci->ladate.year != ffb.fdateLastAccess.year + 1980 || 527 pci->latime.seconds != ffb.ftimeLastAccess.twosecs * 2 || 528 pci->latime.minutes != ffb.ftimeLastAccess.minutes || 529 pci->latime.hours != ffb.ftimeLastAccess.hours) 536 530 { 537 *pci->szFileName = toupper(*pci->szFileName); 538 if (isalpha(*pci->szFileName) && 539 toupper(*pci->szFileName) > 'B') 531 /* changed; update */ 532 pciList[numlist++] = pci; 533 *ffb.achName = 0; 534 ffb.cchName = 0; 535 FillInRecordFromFFB(hwndCnr, 536 pci, 537 filename[x], 538 &ffb, 539 partial, 540 dcd); 541 if (IsRoot(pci->szFileName)) 540 542 { 541 if (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM)542 pci->rc.hptrIcon = hptrCDROM;543 else544 pci->rc.hptrIcon = (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE) ?545 hptrRemovable :546 (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOTE) ?547 hptrRemote :548 (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_ZIPSTREAM) ?549 hptrZipstrm : hptrDrive;550 }551 else552 pci->rc.hptrIcon = hptrFloppy;553 }554 WinSendMsg(hwndCnr,555 CM_SETRECORDEMPHASIS,556 MPFROMP(pci),557 MPFROM2SHORT(FALSE,558 CRA_SELECTED | CRA_CURSORED));559 }560 }561 else562 {563 /* add record */564 if (dcd->type == DIR_FRAME)565 {566 RECORDINSERT ri;567 ULONGLONG ullTotalBytes;568 569 pci = WinSendMsg(hwndCnr,570 CM_ALLOCRECORD,571 MPFROMLONG(EXTRA_RECORD_BYTES),572 MPFROMLONG(1L));573 if (pci)574 {575 ret = TRUE;576 *ffb.achName = 0;577 ullTotalBytes = FillInRecordFromFFB(hwndCnr,578 pci,579 filename[x],580 &ffb,581 partial,582 dcd);583 if(strlen(pci->szFileName) < 4) {584 543 *pci->szFileName = toupper(*pci->szFileName); 585 if(isalpha(*pci->szFileName) && 586 toupper(*pci->szFileName) > 'B') { 587 if(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM) 544 if (isalpha(*pci->szFileName) && 545 toupper(*pci->szFileName) > 'B') 546 { 547 if (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM) 588 548 pci->rc.hptrIcon = hptrCDROM; 589 549 else … … 598 558 pci->rc.hptrIcon = hptrFloppy; 599 559 } 600 memset(&ri,0,sizeof(RECORDINSERT)); 601 ri.cb = sizeof(RECORDINSERT); 602 ri.pRecordOrder = (PRECORDCORE)CMA_END; 603 ri.pRecordParent = (PRECORDCORE)NULL; 604 ri.zOrder = (USHORT)CMA_TOP; 605 ri.cRecordsInsert = 1L; 606 ri.fInvalidateRecord = FALSE; 607 if (WinSendMsg(hwndCnr, 608 CM_INSERTRECORD, 609 MPFROMP(pci), 610 MPFROMP(&ri))) 611 { 612 if (ullTotalBytes) 613 { 614 dcd->ullTotalBytes += ullTotalBytes; 615 numremain++; 616 } 617 repos = TRUE; 618 if(pci->attrFile & FILE_DIRECTORY) 619 Stubby(hwndCnr,pci); 620 } 621 else 622 WinSendMsg(hwndCnr, 623 CM_FREERECORD, 624 MPFROMP(&pci), 625 MPFROMSHORT(1)); 560 WinSendMsg(hwndCnr, 561 CM_SETRECORDEMPHASIS, 562 MPFROMP(pci), 563 MPFROM2SHORT(FALSE, 564 CRA_SELECTED | CRA_CURSORED)); 626 565 } 627 566 } 628 else if (ffb.attrFile & FILE_DIRECTORY) 629 { 630 /* check all parts and insert as required */ 631 CHAR *p,temp; 632 PCNRITEM pciParent = NULL,pciT; 633 634 p = strchr(filename[x],'\\'); 635 if(p) { 636 while(p && *p) { 637 if(p < filename[x] + 3) 638 p++; 639 temp = *p; 640 *p = 0; 641 pciT = FindCnrRecord(hwndCnr, 642 filename[x], 643 NULL, 644 partial, 645 FALSE, 646 TRUE); 647 if(!pciT || (INT)pciT == -1) { 648 pci = WinSendMsg(hwndCnr, 649 CM_ALLOCRECORD, 650 MPFROMLONG(EXTRA_RECORD_BYTES), 651 MPFROMLONG(1L)); 652 if(pci) { 653 654 RECORDINSERT ri; 655 ULONGLONG ullTotalBytes; 656 657 ret = TRUE; 658 *ffb.achName = 0; 659 ullTotalBytes = FillInRecordFromFFB(hwndCnr, 660 pci, 661 filename[x], 662 &ffb, 663 partial, 664 dcd); 665 if(strlen(pci->szFileName) < 4) { 666 *pci->szFileName = toupper(*pci->szFileName); 667 if(isalpha(*pci->szFileName) && 668 toupper(*pci->szFileName) > 'B') { 669 if(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM) 670 pci->rc.hptrIcon = hptrCDROM; 671 else 672 pci->rc.hptrIcon = (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE) ? 673 hptrRemovable : 674 (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOTE) ? 675 hptrRemote : 676 (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_ZIPSTREAM) ? 677 hptrZipstrm : hptrDrive; 678 } 679 else 680 pci->rc.hptrIcon = hptrFloppy; 681 } 682 memset(&ri,0,sizeof(RECORDINSERT)); 683 ri.cb = sizeof(RECORDINSERT); 684 ri.pRecordOrder = (PRECORDCORE)CMA_END; 685 ri.pRecordParent = (PRECORDCORE)pciParent; 686 ri.zOrder = (USHORT)CMA_TOP; 687 ri.cRecordsInsert = 1L; 688 ri.fInvalidateRecord = FALSE; 689 if(WinSendMsg(hwndCnr, 690 CM_INSERTRECORD, 691 MPFROMP(pci), 692 MPFROMP(&ri))) { 693 if (ullTotalBytes) 694 { 695 numremain++; 696 if (dcd->type == DIR_FRAME) 697 dcd->ullTotalBytes += ullTotalBytes; 698 } 699 repos = TRUE; 700 } 701 else 702 WinSendMsg(hwndCnr, 703 CM_FREERECORD, 704 MPFROMP(&pci), 705 MPFROMSHORT(1)); 706 } 707 } 708 else 709 pciParent = pciT; 710 *p = temp; 711 p = strchr(p + ((temp == '\\') ? 1 : 0),'\\'); 712 } 713 } 714 { 567 else 568 { 569 /* add record */ 570 if (dcd->type == DIR_FRAME) 571 { 572 RECORDINSERT ri; 573 ULONGLONG ullTotalBytes; 574 715 575 pci = WinSendMsg(hwndCnr, 716 576 CM_ALLOCRECORD, 717 577 MPFROMLONG(EXTRA_RECORD_BYTES), 718 578 MPFROMLONG(1L)); 719 if(pci) { 720 721 RECORDINSERT ri; 722 ULONGLONG ullTotalBytes; 723 579 if (pci) 580 { 724 581 ret = TRUE; 725 582 *ffb.achName = 0; … … 750 607 ri.cb = sizeof(RECORDINSERT); 751 608 ri.pRecordOrder = (PRECORDCORE)CMA_END; 752 ri.pRecordParent = (PRECORDCORE) pciParent;609 ri.pRecordParent = (PRECORDCORE)NULL; 753 610 ri.zOrder = (USHORT)CMA_TOP; 754 611 ri.cRecordsInsert = 1L; 755 612 ri.fInvalidateRecord = FALSE; 756 if(WinSendMsg(hwndCnr, 757 CM_INSERTRECORD, 758 MPFROMP(pci), 759 MPFROMP(&ri))) { 613 if (WinSendMsg(hwndCnr, 614 CM_INSERTRECORD, 615 MPFROMP(pci), 616 MPFROMP(&ri))) 617 { 760 618 if (ullTotalBytes) 761 { 619 { 620 dcd->ullTotalBytes += ullTotalBytes; 762 621 numremain++; 763 if (dcd->type == DIR_FRAME)764 dcd->ullTotalBytes += ullTotalBytes;765 622 } 766 623 repos = TRUE; 767 Stubby(hwndCnr,pci); 624 if(pci->attrFile & FILE_DIRECTORY) 625 Stubby(hwndCnr,pci); 768 626 } 769 627 else … … 774 632 } 775 633 } 634 else if (ffb.attrFile & FILE_DIRECTORY) 635 { 636 /* check all parts and insert as required */ 637 CHAR *p,temp; 638 PCNRITEM pciParent = NULL,pciT; 639 640 p = strchr(filename[x],'\\'); 641 if(p) { 642 while(p && *p) { 643 if(p < filename[x] + 3) 644 p++; 645 temp = *p; 646 *p = 0; 647 pciT = FindCnrRecord(hwndCnr, 648 filename[x], 649 NULL, 650 partial, 651 FALSE, 652 TRUE); 653 if(!pciT || (INT)pciT == -1) { 654 pci = WinSendMsg(hwndCnr, 655 CM_ALLOCRECORD, 656 MPFROMLONG(EXTRA_RECORD_BYTES), 657 MPFROMLONG(1L)); 658 if(pci) { 659 660 RECORDINSERT ri; 661 ULONGLONG ullTotalBytes; 662 663 ret = TRUE; 664 *ffb.achName = 0; 665 ullTotalBytes = FillInRecordFromFFB(hwndCnr, 666 pci, 667 filename[x], 668 &ffb, 669 partial, 670 dcd); 671 if(strlen(pci->szFileName) < 4) { 672 *pci->szFileName = toupper(*pci->szFileName); 673 if(isalpha(*pci->szFileName) && 674 toupper(*pci->szFileName) > 'B') { 675 if(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM) 676 pci->rc.hptrIcon = hptrCDROM; 677 else 678 pci->rc.hptrIcon = (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE) ? 679 hptrRemovable : 680 (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOTE) ? 681 hptrRemote : 682 (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_ZIPSTREAM) ? 683 hptrZipstrm : hptrDrive; 684 } 685 else 686 pci->rc.hptrIcon = hptrFloppy; 687 } 688 memset(&ri,0,sizeof(RECORDINSERT)); 689 ri.cb = sizeof(RECORDINSERT); 690 ri.pRecordOrder = (PRECORDCORE)CMA_END; 691 ri.pRecordParent = (PRECORDCORE)pciParent; 692 ri.zOrder = (USHORT)CMA_TOP; 693 ri.cRecordsInsert = 1L; 694 ri.fInvalidateRecord = FALSE; 695 if(WinSendMsg(hwndCnr, 696 CM_INSERTRECORD, 697 MPFROMP(pci), 698 MPFROMP(&ri))) { 699 if (ullTotalBytes) 700 { 701 numremain++; 702 if (dcd->type == DIR_FRAME) 703 dcd->ullTotalBytes += ullTotalBytes; 704 } 705 repos = TRUE; 706 } 707 else 708 WinSendMsg(hwndCnr, 709 CM_FREERECORD, 710 MPFROMP(&pci), 711 MPFROMSHORT(1)); 712 } 713 } 714 else 715 pciParent = pciT; 716 *p = temp; 717 p = strchr(p + ((temp == '\\') ? 1 : 0),'\\'); 718 } 719 } 720 { 721 pci = WinSendMsg(hwndCnr, 722 CM_ALLOCRECORD, 723 MPFROMLONG(EXTRA_RECORD_BYTES), 724 MPFROMLONG(1L)); 725 if(pci) { 726 727 RECORDINSERT ri; 728 ULONGLONG ullTotalBytes; 729 730 ret = TRUE; 731 *ffb.achName = 0; 732 ullTotalBytes = FillInRecordFromFFB(hwndCnr, 733 pci, 734 filename[x], 735 &ffb, 736 partial, 737 dcd); 738 if(strlen(pci->szFileName) < 4) { 739 *pci->szFileName = toupper(*pci->szFileName); 740 if(isalpha(*pci->szFileName) && 741 toupper(*pci->szFileName) > 'B') { 742 if(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_CDROM) 743 pci->rc.hptrIcon = hptrCDROM; 744 else 745 pci->rc.hptrIcon = (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE) ? 746 hptrRemovable : 747 (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOTE) ? 748 hptrRemote : 749 (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_ZIPSTREAM) ? 750 hptrZipstrm : hptrDrive; 751 } 752 else 753 pci->rc.hptrIcon = hptrFloppy; 754 } 755 memset(&ri,0,sizeof(RECORDINSERT)); 756 ri.cb = sizeof(RECORDINSERT); 757 ri.pRecordOrder = (PRECORDCORE)CMA_END; 758 ri.pRecordParent = (PRECORDCORE)pciParent; 759 ri.zOrder = (USHORT)CMA_TOP; 760 ri.cRecordsInsert = 1L; 761 ri.fInvalidateRecord = FALSE; 762 if(WinSendMsg(hwndCnr, 763 CM_INSERTRECORD, 764 MPFROMP(pci), 765 MPFROMP(&ri))) { 766 if (ullTotalBytes) 767 { 768 numremain++; 769 if (dcd->type == DIR_FRAME) 770 dcd->ullTotalBytes += ullTotalBytes; 771 } 772 repos = TRUE; 773 Stubby(hwndCnr,pci); 774 } 775 else 776 WinSendMsg(hwndCnr, 777 CM_FREERECORD, 778 MPFROMP(&pci), 779 MPFROMSHORT(1)); 780 } 781 } 782 } 776 783 } 777 784 } 778 } 779 else if ((pci = FindCnrRecord(hwndCnr, 780 filename[x], 781 (PCNRITEM)NULL, 782 partial, 783 FALSE, 784 TRUE)) != NULL && 785 (INT)pci != -1 && 786 !IsRoot(pci->szFileName)) 787 { 788 /* file doesn't exist; delete record */ 789 if(pci->rc.flRecordAttr & CRA_SELECTED) 790 WinSendMsg(hwndCnr, 791 CM_SETRECORDEMPHASIS, 792 MPFROMP(pci), 793 MPFROM2SHORT(FALSE, 794 CRA_SELECTED)); 795 if (dcd->type == DIR_FRAME) 796 dcd->ullTotalBytes -= (pci->cbFile + pci->easize); 797 if (WinSendMsg(hwndCnr, 798 CM_REMOVERECORD, 799 MPFROMP(&pci), 800 MPFROM2SHORT(1, CMA_FREE | (numremain == 1 ? CMA_INVALIDATE : 0)))) 785 else if ((pci = FindCnrRecord(hwndCnr, 786 filename[x], 787 (PCNRITEM)NULL, 788 partial, 789 FALSE, 790 TRUE)) != NULL && 791 (INT)pci != -1 && 792 !IsRoot(pci->szFileName)) 801 793 { 802 numremain--; 803 repos = TRUE; 794 /* file doesn't exist; delete record */ 795 if(pci->rc.flRecordAttr & CRA_SELECTED) 796 WinSendMsg(hwndCnr, 797 CM_SETRECORDEMPHASIS, 798 MPFROMP(pci), 799 MPFROM2SHORT(FALSE, 800 CRA_SELECTED)); 801 if (dcd->type == DIR_FRAME) 802 dcd->ullTotalBytes -= (pci->cbFile + pci->easize); 803 if (WinSendMsg(hwndCnr, 804 CM_REMOVERECORD, 805 MPFROMP(&pci), 806 MPFROM2SHORT(1, CMA_FREE | (numremain == 1 ? CMA_INVALIDATE : 0)))) 807 { 808 numremain--; 809 repos = TRUE; 810 } 804 811 } 805 } 812 } // for 806 813 } 807 814 if (repos || (pciList && numlist)) … … 858 865 MPVOID, 859 866 MPVOID); 860 if (pciList) {867 if (pciList) { 861 868 free(pciList); 862 869 DosPostEventSem(CompactSem);
Note:
See TracChangeset
for help on using the changeset viewer.