aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/Archive/ExtHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/Archive/ExtHandler.cpp')
-rw-r--r--CPP/7zip/Archive/ExtHandler.cpp464
1 files changed, 235 insertions, 229 deletions
diff --git a/CPP/7zip/Archive/ExtHandler.cpp b/CPP/7zip/Archive/ExtHandler.cpp
index 01e12ed..f309485 100644
--- a/CPP/7zip/Archive/ExtHandler.cpp
+++ b/CPP/7zip/Archive/ExtHandler.cpp
@@ -353,7 +353,7 @@ static int inline GetLog(UInt32 num)
353{ 353{
354 for (unsigned i = 0; i < 32; i++) 354 for (unsigned i = 0; i < 32; i++)
355 if (((UInt32)1 << i) == num) 355 if (((UInt32)1 << i) == num)
356 return i; 356 return (int)i;
357 return -1; 357 return -1;
358} 358}
359 359
@@ -371,8 +371,8 @@ bool CHeader::Parse(const Byte *p)
371 if (GetUi16(p + 0x38) != 0xEF53) 371 if (GetUi16(p + 0x38) != 0xEF53)
372 return false; 372 return false;
373 373
374 LE_32 (0x18, BlockBits); 374 LE_32 (0x18, BlockBits)
375 LE_32 (0x1C, ClusterBits); 375 LE_32 (0x1C, ClusterBits)
376 376
377 if (ClusterBits != 0 && BlockBits != ClusterBits) 377 if (ClusterBits != 0 && BlockBits != ClusterBits)
378 return false; 378 return false;
@@ -381,22 +381,22 @@ bool CHeader::Parse(const Byte *p)
381 return false; 381 return false;
382 BlockBits += 10; 382 BlockBits += 10;
383 383
384 LE_32 (0x00, NumInodes); 384 LE_32 (0x00, NumInodes)
385 LE_32 (0x04, NumBlocks); 385 LE_32 (0x04, NumBlocks)
386 // LE_32 (0x08, NumBlocksSuper); 386 // LE_32 (0x08, NumBlocksSuper);
387 LE_32 (0x0C, NumFreeBlocks); 387 LE_32 (0x0C, NumFreeBlocks)
388 LE_32 (0x10, NumFreeInodes); 388 LE_32 (0x10, NumFreeInodes)
389 389
390 if (NumInodes < 2 || NumInodes <= NumFreeInodes) 390 if (NumInodes < 2 || NumInodes <= NumFreeInodes)
391 return false; 391 return false;
392 392
393 UInt32 FirstDataBlock; 393 UInt32 FirstDataBlock;
394 LE_32 (0x14, FirstDataBlock); 394 LE_32 (0x14, FirstDataBlock)
395 if (FirstDataBlock != (unsigned)(BlockBits == 10 ? 1 : 0)) 395 if (FirstDataBlock != (unsigned)(BlockBits == 10 ? 1 : 0))
396 return false; 396 return false;
397 397
398 LE_32 (0x20, BlocksPerGroup); 398 LE_32 (0x20, BlocksPerGroup)
399 LE_32 (0x24, ClustersPerGroup); 399 LE_32 (0x24, ClustersPerGroup)
400 400
401 if (BlocksPerGroup != ClustersPerGroup) 401 if (BlocksPerGroup != ClustersPerGroup)
402 return false; 402 return false;
@@ -408,13 +408,13 @@ bool CHeader::Parse(const Byte *p)
408 // return false; 408 // return false;
409 } 409 }
410 410
411 LE_32 (0x28, InodesPerGroup); 411 LE_32 (0x28, InodesPerGroup)
412 412
413 if (InodesPerGroup < 1 || InodesPerGroup > NumInodes) 413 if (InodesPerGroup < 1 || InodesPerGroup > NumInodes)
414 return false; 414 return false;
415 415
416 LE_32 (0x2C, MountTime); 416 LE_32 (0x2C, MountTime)
417 LE_32 (0x30, WriteTime); 417 LE_32 (0x30, WriteTime)
418 418
419 // LE_16 (0x34, NumMounts); 419 // LE_16 (0x34, NumMounts);
420 // LE_16 (0x36, NumMountsMax); 420 // LE_16 (0x36, NumMountsMax);
@@ -423,10 +423,10 @@ bool CHeader::Parse(const Byte *p)
423 // LE_16 (0x3C, Errors); 423 // LE_16 (0x3C, Errors);
424 // LE_16 (0x3E, MinorRevLevel); 424 // LE_16 (0x3E, MinorRevLevel);
425 425
426 LE_32 (0x40, LastCheckTime); 426 LE_32 (0x40, LastCheckTime)
427 // LE_32 (0x44, CheckInterval); 427 // LE_32 (0x44, CheckInterval);
428 LE_32 (0x48, CreatorOs); 428 LE_32 (0x48, CreatorOs)
429 LE_32 (0x4C, RevLevel); 429 LE_32 (0x4C, RevLevel)
430 430
431 // LE_16 (0x50, DefResUid); 431 // LE_16 (0x50, DefResUid);
432 // LE_16 (0x52, DefResGid); 432 // LE_16 (0x52, DefResGid);
@@ -436,8 +436,8 @@ bool CHeader::Parse(const Byte *p)
436 436
437 if (!IsOldRev()) 437 if (!IsOldRev())
438 { 438 {
439 LE_32 (0x54, FirstInode); 439 LE_32 (0x54, FirstInode)
440 LE_16 (0x58, InodeSize); 440 LE_16 (0x58, InodeSize)
441 if (FirstInode < k_INODE_GOOD_OLD_FIRST) 441 if (FirstInode < k_INODE_GOOD_OLD_FIRST)
442 return false; 442 return false;
443 if (InodeSize > ((UInt32)1 << BlockBits) 443 if (InodeSize > ((UInt32)1 << BlockBits)
@@ -446,10 +446,10 @@ bool CHeader::Parse(const Byte *p)
446 return false; 446 return false;
447 } 447 }
448 448
449 LE_16 (0x5A, BlockGroupNr); 449 LE_16 (0x5A, BlockGroupNr)
450 LE_32 (0x5C, FeatureCompat); 450 LE_32 (0x5C, FeatureCompat)
451 LE_32 (0x60, FeatureIncompat); 451 LE_32 (0x60, FeatureIncompat)
452 LE_32 (0x64, FeatureRoCompat); 452 LE_32 (0x64, FeatureRoCompat)
453 453
454 memcpy(Uuid, p + 0x68, sizeof(Uuid)); 454 memcpy(Uuid, p + 0x68, sizeof(Uuid));
455 memcpy(VolName, p + 0x78, sizeof(VolName)); 455 memcpy(VolName, p + 0x78, sizeof(VolName));
@@ -457,24 +457,24 @@ bool CHeader::Parse(const Byte *p)
457 457
458 // LE_32 (0xC8, BitmapAlgo); 458 // LE_32 (0xC8, BitmapAlgo);
459 459
460 LE_32 (0xE0, JournalInode); 460 LE_32 (0xE0, JournalInode)
461 461
462 LE_16 (0xFE, GdSize); 462 LE_16 (0xFE, GdSize)
463 463
464 LE_32 (0x108, CTime); 464 LE_32 (0x108, CTime)
465 465
466 if (Is64Bit()) 466 if (Is64Bit())
467 { 467 {
468 HI_32(0x150, NumBlocks); 468 HI_32(0x150, NumBlocks)
469 // HI_32(0x154, NumBlocksSuper); 469 // HI_32(0x154, NumBlocksSuper);
470 HI_32(0x158, NumFreeBlocks); 470 HI_32(0x158, NumFreeBlocks)
471 } 471 }
472 472
473 if (NumBlocks >= (UInt64)1 << (63 - BlockBits)) 473 if (NumBlocks >= (UInt64)1 << (63 - BlockBits))
474 return false; 474 return false;
475 475
476 476
477 LE_16(0x15C, MinExtraISize); 477 LE_16(0x15C, MinExtraISize)
478 // LE_16(0x15E, WantExtraISize); 478 // LE_16(0x15E, WantExtraISize);
479 // LE_32(0x160, Flags); 479 // LE_32(0x160, Flags);
480 // LE_16(0x164, RaidStride); 480 // LE_16(0x164, RaidStride);
@@ -484,7 +484,7 @@ bool CHeader::Parse(const Byte *p)
484 // LogGroupsPerFlex = p[0x174]; 484 // LogGroupsPerFlex = p[0x174];
485 // ChecksumType = p[0x175]; 485 // ChecksumType = p[0x175];
486 486
487 LE_64 (0x178, WrittenKB); 487 LE_64 (0x178, WrittenKB)
488 488
489 // LE_32(0x194, ErrorCount); 489 // LE_32(0x194, ErrorCount);
490 // LE_32(0x198, ErrorTime); 490 // LE_32(0x198, ErrorTime);
@@ -525,32 +525,32 @@ struct CGroupDescriptor
525 525
526void CGroupDescriptor::Parse(const Byte *p, unsigned size) 526void CGroupDescriptor::Parse(const Byte *p, unsigned size)
527{ 527{
528 LE_32 (0x00, BlockBitmap); 528 LE_32 (0x00, BlockBitmap)
529 LE_32 (0x04, InodeBitmap); 529 LE_32 (0x04, InodeBitmap)
530 LE_32 (0x08, InodeTable); 530 LE_32 (0x08, InodeTable)
531 LE_16 (0x0C, NumFreeBlocks); 531 LE_16 (0x0C, NumFreeBlocks)
532 LE_16 (0x0E, NumFreeInodes); 532 LE_16 (0x0E, NumFreeInodes)
533 LE_16 (0x10, DirCount); 533 LE_16 (0x10, DirCount)
534 LE_16 (0x12, Flags); 534 LE_16 (0x12, Flags)
535 LE_32 (0x14, ExcludeBitmap); 535 LE_32 (0x14, ExcludeBitmap)
536 LE_16 (0x18, BlockBitmap_Checksum); 536 LE_16 (0x18, BlockBitmap_Checksum)
537 LE_16 (0x1A, InodeBitmap_Checksum); 537 LE_16 (0x1A, InodeBitmap_Checksum)
538 LE_16 (0x1C, UnusedCount); 538 LE_16 (0x1C, UnusedCount)
539 LE_16 (0x1E, Checksum); 539 LE_16 (0x1E, Checksum)
540 540
541 if (size >= 64) 541 if (size >= 64)
542 { 542 {
543 p += 0x20; 543 p += 0x20;
544 HI_32 (0x00, BlockBitmap); 544 HI_32 (0x00, BlockBitmap)
545 HI_32 (0x04, InodeBitmap); 545 HI_32 (0x04, InodeBitmap)
546 HI_32 (0x08, InodeTable); 546 HI_32 (0x08, InodeTable)
547 HI_16 (0x0C, NumFreeBlocks); 547 HI_16 (0x0C, NumFreeBlocks)
548 HI_16 (0x0E, NumFreeInodes); 548 HI_16 (0x0E, NumFreeInodes)
549 HI_16 (0x10, DirCount); 549 HI_16 (0x10, DirCount)
550 HI_16 (0x12, UnusedCount); // instead of Flags 550 HI_16 (0x12, UnusedCount) // instead of Flags
551 HI_32 (0x14, ExcludeBitmap); 551 HI_32 (0x14, ExcludeBitmap)
552 HI_16 (0x18, BlockBitmap_Checksum); 552 HI_16 (0x18, BlockBitmap_Checksum)
553 HI_16 (0x1A, InodeBitmap_Checksum); 553 HI_16 (0x1A, InodeBitmap_Checksum)
554 // HI_16 (0x1C, Reserved); 554 // HI_16 (0x1C, Reserved);
555 } 555 }
556} 556}
@@ -567,9 +567,9 @@ struct CExtentTreeHeader
567 567
568 bool Parse(const Byte *p) 568 bool Parse(const Byte *p)
569 { 569 {
570 LE_16 (0x02, NumEntries); 570 LE_16 (0x02, NumEntries)
571 LE_16 (0x04, MaxEntries); 571 LE_16 (0x04, MaxEntries)
572 LE_16 (0x06, Depth); 572 LE_16 (0x06, Depth)
573 // LE_32 (0x08, Generation); 573 // LE_32 (0x08, Generation);
574 return Get16(p) == 0xF30A; // magic 574 return Get16(p) == 0xF30A; // magic
575 } 575 }
@@ -582,8 +582,8 @@ struct CExtentIndexNode
582 582
583 void Parse(const Byte *p) 583 void Parse(const Byte *p)
584 { 584 {
585 LE_32 (0x00, VirtBlock); 585 LE_32 (0x00, VirtBlock)
586 LE_32 (0x04, PhyLeaf); 586 LE_32 (0x04, PhyLeaf)
587 PhyLeaf |= (((UInt64)Get16(p + 8)) << 32); 587 PhyLeaf |= (((UInt64)Get16(p + 8)) << 32);
588 // unused 16-bit field (at offset 0x0A) can be not zero in some cases. Why? 588 // unused 16-bit field (at offset 0x0A) can be not zero in some cases. Why?
589 } 589 }
@@ -601,17 +601,17 @@ struct CExtent
601 601
602 void Parse(const Byte *p) 602 void Parse(const Byte *p)
603 { 603 {
604 LE_32 (0x00, VirtBlock); 604 LE_32 (0x00, VirtBlock)
605 LE_16 (0x04, Len); 605 LE_16 (0x04, Len)
606 IsInited = true; 606 IsInited = true;
607 if (Len > (UInt32)0x8000) 607 if (Len > (UInt32)0x8000)
608 { 608 {
609 IsInited = false; 609 IsInited = false;
610 Len = (UInt16)(Len - (UInt32)0x8000); 610 Len = (UInt16)(Len - (UInt32)0x8000);
611 } 611 }
612 LE_32 (0x08, PhyStart); 612 LE_32 (0x08, PhyStart)
613 UInt16 hi; 613 UInt16 hi;
614 LE_16 (0x06, hi); 614 LE_16 (0x06, hi)
615 PhyStart |= ((UInt64)hi << 32); 615 PhyStart |= ((UInt64)hi << 32);
616 } 616 }
617}; 617};
@@ -627,7 +627,7 @@ struct CExtTime
627struct CNode 627struct CNode
628{ 628{
629 Int32 ParentNode; // in _refs[], -1 if not dir 629 Int32 ParentNode; // in _refs[], -1 if not dir
630 int ItemIndex; // in _items[] 630 int ItemIndex; // in _items[] , (set as >=0 only for if (IsDir())
631 int SymLinkIndex; // in _symLinks[] 631 int SymLinkIndex; // in _symLinks[]
632 int DirIndex; // in _dirs[] 632 int DirIndex; // in _dirs[]
633 633
@@ -655,7 +655,7 @@ struct CNode
655 ParentNode(-1), 655 ParentNode(-1),
656 ItemIndex(-1), 656 ItemIndex(-1),
657 SymLinkIndex(-1), 657 SymLinkIndex(-1),
658 DirIndex(0), 658 DirIndex(-1),
659 NumLinksCalced(0) 659 NumLinksCalced(0)
660 {} 660 {}
661 661
@@ -679,18 +679,18 @@ bool CNode::Parse(const Byte *p, const CHeader &_h)
679 ChangeTime.Extra = 0; 679 ChangeTime.Extra = 0;
680 // DTime.Extra = 0; 680 // DTime.Extra = 0;
681 681
682 LE_16 (0x00, Mode); 682 LE_16 (0x00, Mode)
683 LE_16 (0x02, Uid); 683 LE_16 (0x02, Uid)
684 LE_32 (0x04, FileSize); 684 LE_32 (0x04, FileSize)
685 LE_32 (0x08, ATime.Val); 685 LE_32 (0x08, ATime.Val)
686 LE_32 (0x0C, ChangeTime.Val); 686 LE_32 (0x0C, ChangeTime.Val)
687 LE_32 (0x10, MTime.Val); 687 LE_32 (0x10, MTime.Val)
688 // LE_32 (0x14, DTime.Val); 688 // LE_32 (0x14, DTime.Val);
689 LE_16 (0x18, Gid); 689 LE_16 (0x18, Gid)
690 LE_16 (0x1A, NumLinks); 690 LE_16 (0x1A, NumLinks)
691 691
692 LE_32 (0x1C, NumBlocks); 692 LE_32 (0x1C, NumBlocks)
693 LE_32 (0x20, Flags); 693 LE_32 (0x20, Flags)
694 // LE_32 (0x24, Union osd1); 694 // LE_32 (0x24, Union osd1);
695 695
696 memcpy(Block, p + 0x28, kNodeBlockFieldSize); 696 memcpy(Block, p + 0x28, kNodeBlockFieldSize);
@@ -700,7 +700,7 @@ bool CNode::Parse(const Byte *p, const CHeader &_h)
700 700
701 { 701 {
702 UInt32 highSize; 702 UInt32 highSize;
703 LE_32 (0x6C, highSize); // In ext2/3 this field was named i_dir_acl 703 LE_32 (0x6C, highSize) // In ext2/3 this field was named i_dir_acl
704 704
705 if (IsRegular()) // do we need that check ? 705 if (IsRegular()) // do we need that check ?
706 FileSize |= ((UInt64)highSize << 32); 706 FileSize |= ((UInt64)highSize << 32);
@@ -718,11 +718,11 @@ bool CNode::Parse(const Byte *p, const CHeader &_h)
718 718
719 // ext4: 719 // ext4:
720 UInt32 numBlocksHigh; 720 UInt32 numBlocksHigh;
721 LE_16 (0x74, numBlocksHigh); 721 LE_16 (0x74, numBlocksHigh)
722 NumBlocks |= (UInt64)numBlocksHigh << 32; 722 NumBlocks |= (UInt64)numBlocksHigh << 32;
723 723
724 HI_16 (0x74 + 4, Uid); 724 HI_16 (0x74 + 4, Uid)
725 HI_16 (0x74 + 6, Gid); 725 HI_16 (0x74 + 6, Gid)
726 /* 726 /*
727 UInt32 checksum; 727 UInt32 checksum;
728 LE_16 (0x74 + 8, checksum); 728 LE_16 (0x74 + 8, checksum);
@@ -737,19 +737,19 @@ bool CNode::Parse(const Byte *p, const CHeader &_h)
737 // InodeSize is power of 2, so the following check is not required: 737 // InodeSize is power of 2, so the following check is not required:
738 // if (_h.InodeSize < 128 + 2) return false; 738 // if (_h.InodeSize < 128 + 2) return false;
739 UInt16 extra_isize; 739 UInt16 extra_isize;
740 LE_16 (0x80, extra_isize); 740 LE_16 (0x80, extra_isize)
741 if (128 + extra_isize > _h.InodeSize) 741 if (128 + extra_isize > _h.InodeSize)
742 return false; 742 return false;
743 if (extra_isize >= 0x1C) 743 if (extra_isize >= 0x1C)
744 { 744 {
745 // UInt16 checksumUpper; 745 // UInt16 checksumUpper;
746 // LE_16 (0x82, checksumUpper); 746 // LE_16 (0x82, checksumUpper);
747 LE_32 (0x84, ChangeTime.Extra); 747 LE_32 (0x84, ChangeTime.Extra)
748 LE_32 (0x88, MTime.Extra); 748 LE_32 (0x88, MTime.Extra)
749 LE_32 (0x8C, ATime.Extra); 749 LE_32 (0x8C, ATime.Extra)
750 LE_32 (0x90, CTime.Val); 750 LE_32 (0x90, CTime.Val)
751 LE_32 (0x94, CTime.Extra); 751 LE_32 (0x94, CTime.Extra)
752 // LE_32 (0x98, VersionHi); 752 // LE_32 (0x98, VersionHi)
753 } 753 }
754 } 754 }
755 755
@@ -786,7 +786,6 @@ struct CItem
786 786
787 bool IsDir() const { return Type == k_Type_DIR; } 787 bool IsDir() const { return Type == k_Type_DIR; }
788 // bool IsNotDir() const { return Type != k_Type_DIR && Type != k_Type_UNKNOWN; } 788 // bool IsNotDir() const { return Type != k_Type_DIR && Type != k_Type_UNKNOWN; }
789
790}; 789};
791 790
792 791
@@ -794,14 +793,12 @@ struct CItem
794static const unsigned kNumTreeLevelsMax = 6; // must be >= 3 793static const unsigned kNumTreeLevelsMax = 6; // must be >= 3
795 794
796 795
797class CHandler: 796Z7_CLASS_IMP_CHandler_IInArchive_2(
798 public IInArchive, 797 IArchiveGetRawProps,
799 public IArchiveGetRawProps, 798 IInArchiveGetStream
800 public IInArchiveGetStream, 799)
801 public CMyUnknownImp
802{
803 CObjectVector<CItem> _items; 800 CObjectVector<CItem> _items;
804 CIntVector _refs; 801 CIntVector _refs; // iNode -> (index in _nodes). if (_refs[iNode] < 0), that node is not filled
805 CRecordVector<CNode> _nodes; 802 CRecordVector<CNode> _nodes;
806 CObjectVector<CUIntVector> _dirs; // each CUIntVector contains indexes in _items[] only for dir items; 803 CObjectVector<CUIntVector> _dirs; // each CUIntVector contains indexes in _items[] only for dir items;
807 AStringVector _symLinks; 804 AStringVector _symLinks;
@@ -871,16 +868,6 @@ class CHandler:
871 868
872 void GetPath(unsigned index, AString &s) const; 869 void GetPath(unsigned index, AString &s) const;
873 bool GetPackSize(unsigned index, UInt64 &res) const; 870 bool GetPackSize(unsigned index, UInt64 &res) const;
874
875public:
876 CHandler() {}
877 ~CHandler() {}
878
879 MY_UNKNOWN_IMP3(IInArchive, IArchiveGetRawProps, IInArchiveGetStream)
880
881 INTERFACE_IInArchive(;)
882 INTERFACE_IArchiveGetRawProps(;)
883 STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
884}; 871};
885 872
886 873
@@ -892,7 +879,7 @@ HRESULT CHandler::ParseDir(const Byte *p, size_t size, unsigned iNodeDir)
892 PRF(printf("\n\n========= node = %5d size = %5d", (unsigned)iNodeDir, (unsigned)size)); 879 PRF(printf("\n\n========= node = %5d size = %5d", (unsigned)iNodeDir, (unsigned)size));
893 880
894 CNode &nodeDir = _nodes[_refs[iNodeDir]]; 881 CNode &nodeDir = _nodes[_refs[iNodeDir]];
895 nodeDir.DirIndex = _dirs.Size(); 882 nodeDir.DirIndex = (int)_dirs.Size();
896 CUIntVector &dir = _dirs.AddNew(); 883 CUIntVector &dir = _dirs.AddNew();
897 int parentNode = -1; 884 int parentNode = -1;
898 885
@@ -905,11 +892,11 @@ HRESULT CHandler::ParseDir(const Byte *p, size_t size, unsigned iNodeDir)
905 if (size < 8) 892 if (size < 8)
906 return S_FALSE; 893 return S_FALSE;
907 UInt32 iNode; 894 UInt32 iNode;
908 LE_32 (0x00, iNode); 895 LE_32 (0x00, iNode)
909 unsigned recLen; 896 unsigned recLen;
910 LE_16 (0x04, recLen); 897 LE_16 (0x04, recLen)
911 unsigned nameLen = p[6]; 898 const unsigned nameLen = p[6];
912 Byte type = p[7]; 899 const Byte type = p[7];
913 900
914 if (recLen > size) 901 if (recLen > size)
915 return S_FALSE; 902 return S_FALSE;
@@ -926,7 +913,7 @@ HRESULT CHandler::ParseDir(const Byte *p, size_t size, unsigned iNodeDir)
926 else if (type != 0) 913 else if (type != 0)
927 return S_FALSE; 914 return S_FALSE;
928 915
929 item.ParentNode = iNodeDir; 916 item.ParentNode = (int)iNodeDir;
930 item.Node = iNode; 917 item.Node = iNode;
931 item.Name.SetFrom_CalcLen((const char *)(p + 8), nameLen); 918 item.Name.SetFrom_CalcLen((const char *)(p + 8), nameLen);
932 919
@@ -958,14 +945,14 @@ HRESULT CHandler::ParseDir(const Byte *p, size_t size, unsigned iNodeDir)
958 continue; 945 continue;
959 } 946 }
960 947
961 int nodeIndex = _refs[iNode]; 948 const int nodeIndex = _refs[iNode];
962 if (nodeIndex < 0) 949 if (nodeIndex < 0)
963 return S_FALSE; 950 return S_FALSE;
964 CNode &node = _nodes[nodeIndex]; 951 CNode &node = _nodes[nodeIndex];
965 952
966 if (_h.IsThereFileType() && type != 0) 953 if (_h.IsThereFileType() && type != 0)
967 { 954 {
968 if (type >= ARRAY_SIZE(k_TypeToMode)) 955 if (type >= Z7_ARRAY_SIZE(k_TypeToMode))
969 return S_FALSE; 956 return S_FALSE;
970 if (k_TypeToMode[type] != (node.Mode & MY_LIN_S_IFMT)) 957 if (k_TypeToMode[type] != (node.Mode & MY_LIN_S_IFMT))
971 return S_FALSE; 958 return S_FALSE;
@@ -996,10 +983,10 @@ HRESULT CHandler::ParseDir(const Byte *p, size_t size, unsigned iNodeDir)
996 if (iNode == iNodeDir && iNode != k_INODE_ROOT) 983 if (iNode == iNodeDir && iNode != k_INODE_ROOT)
997 return S_FALSE; 984 return S_FALSE;
998 985
999 parentNode = iNode; 986 parentNode = (int)iNode;
1000 987
1001 if (nodeDir.ParentNode < 0) 988 if (nodeDir.ParentNode < 0)
1002 nodeDir.ParentNode = iNode; 989 nodeDir.ParentNode = (int)iNode;
1003 else if ((unsigned)nodeDir.ParentNode != iNode) 990 else if ((unsigned)nodeDir.ParentNode != iNode)
1004 return S_FALSE; 991 return S_FALSE;
1005 992
@@ -1016,12 +1003,12 @@ HRESULT CHandler::ParseDir(const Byte *p, size_t size, unsigned iNodeDir)
1016 if (node.IsDir()) 1003 if (node.IsDir())
1017 { 1004 {
1018 if (node.ParentNode < 0) 1005 if (node.ParentNode < 0)
1019 node.ParentNode = iNodeDir; 1006 node.ParentNode = (int)iNodeDir;
1020 else if ((unsigned)node.ParentNode != iNodeDir) 1007 else if ((unsigned)node.ParentNode != iNodeDir)
1021 return S_FALSE; 1008 return S_FALSE;
1022 const unsigned itemIndex = _items.Size(); 1009 const unsigned itemIndex = _items.Size();
1023 dir.Add(itemIndex); 1010 dir.Add(itemIndex);
1024 node.ItemIndex = itemIndex; 1011 node.ItemIndex = (int)itemIndex;
1025 } 1012 }
1026 1013
1027 _items.Add(item); 1014 _items.Add(item);
@@ -1034,6 +1021,13 @@ HRESULT CHandler::ParseDir(const Byte *p, size_t size, unsigned iNodeDir)
1034} 1021}
1035 1022
1036 1023
1024static int CompareItemsNames(const unsigned *p1, const unsigned *p2, void *param)
1025{
1026 const CObjectVector<CItem> &items = *(const CObjectVector<CItem> *)param;
1027 return strcmp(items[*p1].Name, items[*p2].Name);
1028}
1029
1030
1037int CHandler::FindTargetItem_for_SymLink(unsigned iNode, const AString &path) const 1031int CHandler::FindTargetItem_for_SymLink(unsigned iNode, const AString &path) const
1038{ 1032{
1039 unsigned pos = 0; 1033 unsigned pos = 0;
@@ -1054,7 +1048,7 @@ int CHandler::FindTargetItem_for_SymLink(unsigned iNode, const AString &path) co
1054 while (pos != path.Len()) 1048 while (pos != path.Len())
1055 { 1049 {
1056 const CNode &node = _nodes[_refs[iNode]]; 1050 const CNode &node = _nodes[_refs[iNode]];
1057 int slash = path.Find('/', pos); 1051 const int slash = path.Find('/', pos);
1058 1052
1059 if (slash < 0) 1053 if (slash < 0)
1060 { 1054 {
@@ -1063,8 +1057,8 @@ int CHandler::FindTargetItem_for_SymLink(unsigned iNode, const AString &path) co
1063 } 1057 }
1064 else 1058 else
1065 { 1059 {
1066 s.SetFrom(path.Ptr(pos), slash - pos); 1060 s.SetFrom(path.Ptr(pos), (unsigned)slash - pos);
1067 pos = slash + 1; 1061 pos = (unsigned)slash + 1;
1068 } 1062 }
1069 1063
1070 if (s[0] == '.') 1064 if (s[0] == '.')
@@ -1077,7 +1071,7 @@ int CHandler::FindTargetItem_for_SymLink(unsigned iNode, const AString &path) co
1077 return -1; 1071 return -1;
1078 if (iNode == k_INODE_ROOT) 1072 if (iNode == k_INODE_ROOT)
1079 return -1; 1073 return -1;
1080 iNode = node.ParentNode; 1074 iNode = (unsigned)node.ParentNode;
1081 continue; 1075 continue;
1082 } 1076 }
1083 } 1077 }
@@ -1087,6 +1081,7 @@ int CHandler::FindTargetItem_for_SymLink(unsigned iNode, const AString &path) co
1087 1081
1088 const CUIntVector &dir = _dirs[node.DirIndex]; 1082 const CUIntVector &dir = _dirs[node.DirIndex];
1089 1083
1084 /*
1090 for (unsigned i = 0;; i++) 1085 for (unsigned i = 0;; i++)
1091 { 1086 {
1092 if (i >= dir.Size()) 1087 if (i >= dir.Size())
@@ -1098,6 +1093,26 @@ int CHandler::FindTargetItem_for_SymLink(unsigned iNode, const AString &path) co
1098 break; 1093 break;
1099 } 1094 }
1100 } 1095 }
1096 */
1097
1098 unsigned left = 0, right = dir.Size();
1099 for (;;)
1100 {
1101 if (left == right)
1102 return -1;
1103 const unsigned mid = (unsigned)(((size_t)left + (size_t)right) / 2);
1104 const CItem &item = _items[dir[mid]];
1105 const int comp = strcmp(s, item.Name);
1106 if (comp == 0)
1107 {
1108 iNode = item.Node;
1109 break;
1110 }
1111 if (comp < 0)
1112 right = mid;
1113 else
1114 left = mid + 1;
1115 }
1101 } 1116 }
1102 1117
1103 return _nodes[_refs[iNode]].ItemIndex; 1118 return _nodes[_refs[iNode]].ItemIndex;
@@ -1110,7 +1125,7 @@ HRESULT CHandler::SeekAndRead(IInStream *inStream, UInt64 block, Byte *data, siz
1110 return S_FALSE; 1125 return S_FALSE;
1111 if (((size + ((size_t)1 << _h.BlockBits) - 1) >> _h.BlockBits) > _h.NumBlocks - block) 1126 if (((size + ((size_t)1 << _h.BlockBits) - 1) >> _h.BlockBits) > _h.NumBlocks - block)
1112 return S_FALSE; 1127 return S_FALSE;
1113 RINOK(inStream->Seek((UInt64)block << _h.BlockBits, STREAM_SEEK_SET, NULL)); 1128 RINOK(InStream_SeekSet(inStream, (UInt64)block << _h.BlockBits))
1114 _totalRead += size; 1129 _totalRead += size;
1115 return ReadStream_FALSE(inStream, data, size); 1130 return ReadStream_FALSE(inStream, data, size);
1116} 1131}
@@ -1123,7 +1138,7 @@ HRESULT CHandler::Open2(IInStream *inStream)
1123{ 1138{
1124 { 1139 {
1125 Byte buf[kHeaderSize]; 1140 Byte buf[kHeaderSize];
1126 RINOK(ReadStream_FALSE(inStream, buf, kHeaderSize)); 1141 RINOK(ReadStream_FALSE(inStream, buf, kHeaderSize))
1127 if (!_h.Parse(buf + kHeaderDataOffset)) 1142 if (!_h.Parse(buf + kHeaderDataOffset))
1128 return S_FALSE; 1143 return S_FALSE;
1129 if (_h.BlockGroupNr != 0) 1144 if (_h.BlockGroupNr != 0)
@@ -1135,7 +1150,7 @@ HRESULT CHandler::Open2(IInStream *inStream)
1135 1150
1136 unsigned numGroups; 1151 unsigned numGroups;
1137 { 1152 {
1138 UInt64 numGroups64 = _h.GetNumGroups(); 1153 const UInt64 numGroups64 = _h.GetNumGroups();
1139 if (numGroups64 > (UInt32)1 << 31) 1154 if (numGroups64 > (UInt32)1 << 31)
1140 return S_FALSE; 1155 return S_FALSE;
1141 numGroups = (unsigned)numGroups64; 1156 numGroups = (unsigned)numGroups64;
@@ -1154,11 +1169,11 @@ HRESULT CHandler::Open2(IInStream *inStream)
1154 1169
1155 if (_openCallback) 1170 if (_openCallback)
1156 { 1171 {
1157 RINOK(_openCallback->SetTotal(NULL, &_phySize)); 1172 RINOK(_openCallback->SetTotal(NULL, &_phySize))
1158 } 1173 }
1159 1174
1160 UInt64 fileSize = 0; 1175 UInt64 fileSize = 0;
1161 RINOK(inStream->Seek(0, STREAM_SEEK_END, &fileSize)); 1176 RINOK(InStream_GetSize_SeekToEnd(inStream, fileSize))
1162 1177
1163 CRecordVector<CGroupDescriptor> groups; 1178 CRecordVector<CGroupDescriptor> groups;
1164 1179
@@ -1166,18 +1181,18 @@ HRESULT CHandler::Open2(IInStream *inStream)
1166 // ---------- Read groups ---------- 1181 // ---------- Read groups ----------
1167 1182
1168 CByteBuffer gdBuf; 1183 CByteBuffer gdBuf;
1169 size_t gdBufSize = (size_t)numGroups << gdBits; 1184 const size_t gdBufSize = (size_t)numGroups << gdBits;
1170 if ((gdBufSize >> gdBits) != numGroups) 1185 if ((gdBufSize >> gdBits) != numGroups)
1171 return S_FALSE; 1186 return S_FALSE;
1172 gdBuf.Alloc(gdBufSize); 1187 gdBuf.Alloc(gdBufSize);
1173 RINOK(SeekAndRead(inStream, (_h.BlockBits <= 10 ? 2 : 1), gdBuf, gdBufSize)); 1188 RINOK(SeekAndRead(inStream, (_h.BlockBits <= 10 ? 2 : 1), gdBuf, gdBufSize))
1174 1189
1175 for (unsigned i = 0; i < numGroups; i++) 1190 for (unsigned i = 0; i < numGroups; i++)
1176 { 1191 {
1177 CGroupDescriptor gd; 1192 CGroupDescriptor gd;
1178 1193
1179 const Byte *p = gdBuf + ((size_t)i << gdBits); 1194 const Byte *p = gdBuf + ((size_t)i << gdBits);
1180 unsigned gd_Size = (unsigned)1 << gdBits; 1195 const unsigned gd_Size = (unsigned)1 << gdBits;
1181 gd.Parse(p, gd_Size); 1196 gd.Parse(p, gd_Size);
1182 1197
1183 if (_h.UseMetadataChecksum()) 1198 if (_h.UseMetadataChecksum())
@@ -1188,7 +1203,7 @@ HRESULT CHandler::Open2(IInStream *inStream)
1188 { 1203 {
1189 UInt32 crc = Crc16Calc(_h.Uuid, sizeof(_h.Uuid)); 1204 UInt32 crc = Crc16Calc(_h.Uuid, sizeof(_h.Uuid));
1190 Byte i_le[4]; 1205 Byte i_le[4];
1191 SetUi32(i_le, i); 1206 SetUi32(i_le, i)
1192 crc = Crc16Update(crc, i_le, 4); 1207 crc = Crc16Update(crc, i_le, 4);
1193 crc = Crc16Update(crc, p, 32 - 2); 1208 crc = Crc16Update(crc, p, 32 - 2);
1194 if (gd_Size != 32) 1209 if (gd_Size != 32)
@@ -1250,8 +1265,8 @@ HRESULT CHandler::Open2(IInStream *inStream)
1250 1265
1251 PRF(printf("\n\ng%6d block = %6x\n", gi, (unsigned)gd.InodeTable)); 1266 PRF(printf("\n\ng%6d block = %6x\n", gi, (unsigned)gd.InodeTable));
1252 1267
1253 RINOK(SeekAndRead(inStream, gd.InodeBitmap, nodesMap, blockSize)); 1268 RINOK(SeekAndRead(inStream, gd.InodeBitmap, nodesMap, blockSize))
1254 RINOK(SeekAndRead(inStream, gd.InodeTable, nodesData, nodesDataSize)); 1269 RINOK(SeekAndRead(inStream, gd.InodeTable, nodesData, nodesDataSize))
1255 1270
1256 unsigned numEmpty_in_Map = 0; 1271 unsigned numEmpty_in_Map = 0;
1257 1272
@@ -1300,7 +1315,7 @@ HRESULT CHandler::Open2(IInStream *inStream)
1300 _refs.Add(-1); 1315 _refs.Add(-1);
1301 } 1316 }
1302 1317
1303 _refs.Add(_nodes.Add(node)); 1318 _refs.Add((int)_nodes.Add(node));
1304 } 1319 }
1305 1320
1306 1321
@@ -1336,7 +1351,7 @@ HRESULT CHandler::Open2(IInStream *inStream)
1336 1351
1337 FOR_VECTOR (i, _refs) 1352 FOR_VECTOR (i, _refs)
1338 { 1353 {
1339 int nodeIndex = _refs[i]; 1354 const int nodeIndex = _refs[i];
1340 { 1355 {
1341 if (nodeIndex < 0) 1356 if (nodeIndex < 0)
1342 continue; 1357 continue;
@@ -1344,7 +1359,7 @@ HRESULT CHandler::Open2(IInStream *inStream)
1344 if (!node.IsDir()) 1359 if (!node.IsDir())
1345 continue; 1360 continue;
1346 } 1361 }
1347 RINOK(ExtractNode(nodeIndex, dataBuf)); 1362 RINOK(ExtractNode((unsigned)nodeIndex, dataBuf))
1348 if (dataBuf.Size() == 0) 1363 if (dataBuf.Size() == 0)
1349 { 1364 {
1350 // _headersError = true; 1365 // _headersError = true;
@@ -1352,12 +1367,12 @@ HRESULT CHandler::Open2(IInStream *inStream)
1352 } 1367 }
1353 else 1368 else
1354 { 1369 {
1355 RINOK(ParseDir(dataBuf, dataBuf.Size(), i)); 1370 RINOK(ParseDir(dataBuf, dataBuf.Size(), i))
1356 } 1371 }
1357 RINOK(CheckProgress()); 1372 RINOK(CheckProgress())
1358 } 1373 }
1359 1374
1360 int ref = _refs[k_INODE_ROOT]; 1375 const int ref = _refs[k_INODE_ROOT];
1361 if (ref < 0 || _nodes[ref].ParentNode != k_INODE_ROOT) 1376 if (ref < 0 || _nodes[ref].ParentNode != k_INODE_ROOT)
1362 return S_FALSE; 1377 return S_FALSE;
1363 } 1378 }
@@ -1423,7 +1438,7 @@ HRESULT CHandler::Open2(IInStream *inStream)
1423 1438
1424 for (;;) 1439 for (;;)
1425 { 1440 {
1426 int nodeIndex = _refs[c]; 1441 const int nodeIndex = _refs[c];
1427 if (nodeIndex < 0) 1442 if (nodeIndex < 0)
1428 return S_FALSE; 1443 return S_FALSE;
1429 CNode &node = _nodes[nodeIndex]; 1444 CNode &node = _nodes[nodeIndex];
@@ -1435,12 +1450,12 @@ HRESULT CHandler::Open2(IInStream *inStream)
1435 break; 1450 break;
1436 } 1451 }
1437 1452
1438 UsedByNode[c] = i; 1453 UsedByNode[c] = (int)i;
1439 if (node.ParentNode < 0 || node.ParentNode == k_INODE_ROOT) 1454 if (node.ParentNode < 0 || node.ParentNode == k_INODE_ROOT)
1440 break; 1455 break;
1441 if ((unsigned)node.ParentNode == i) 1456 if ((unsigned)node.ParentNode == i)
1442 return S_FALSE; 1457 return S_FALSE;
1443 c = node.ParentNode; 1458 c = (unsigned)node.ParentNode;
1444 } 1459 }
1445 } 1460 }
1446 } 1461 }
@@ -1454,7 +1469,7 @@ HRESULT CHandler::Open2(IInStream *inStream)
1454 unsigned i; 1469 unsigned i;
1455 for (i = 0; i < _refs.Size(); i++) 1470 for (i = 0; i < _refs.Size(); i++)
1456 { 1471 {
1457 int nodeIndex = _refs[i]; 1472 const int nodeIndex = _refs[i];
1458 if (nodeIndex < 0) 1473 if (nodeIndex < 0)
1459 continue; 1474 continue;
1460 CNode &node = _nodes[nodeIndex]; 1475 CNode &node = _nodes[nodeIndex];
@@ -1462,32 +1477,37 @@ HRESULT CHandler::Open2(IInStream *inStream)
1462 continue; 1477 continue;
1463 if (node.FileSize > ((UInt32)1 << 14)) 1478 if (node.FileSize > ((UInt32)1 << 14))
1464 continue; 1479 continue;
1465 if (ExtractNode(nodeIndex, data) == S_OK && data.Size() != 0) 1480 if (ExtractNode((unsigned)nodeIndex, data) == S_OK && data.Size() != 0)
1466 { 1481 {
1467 s.SetFrom_CalcLen((const char *)(const Byte *)data, (unsigned)data.Size()); 1482 s.SetFrom_CalcLen((const char *)(const Byte *)data, (unsigned)data.Size());
1468 if (s.Len() == data.Size()) 1483 if (s.Len() == data.Size())
1469 node.SymLinkIndex = _symLinks.Add(s); 1484 node.SymLinkIndex = (int)_symLinks.Add(s);
1470 RINOK(CheckProgress()); 1485 RINOK(CheckProgress())
1471 } 1486 }
1472 } 1487 }
1473 1488
1489 for (i = 0; i < _dirs.Size(); i++)
1490 {
1491 _dirs[i].Sort(CompareItemsNames, (void *)&_items);
1492 }
1493
1474 unsigned prev = 0; 1494 unsigned prev = 0;
1475 unsigned complex = 0; 1495 unsigned complex = 0;
1476 1496
1477 for (i = 0; i < _items.Size(); i++) 1497 for (i = 0; i < _items.Size(); i++)
1478 { 1498 {
1479 CItem &item = _items[i]; 1499 CItem &item = _items[i];
1480 int sym = _nodes[_refs[item.Node]].SymLinkIndex; 1500 const int sym = _nodes[_refs[item.Node]].SymLinkIndex;
1481 if (sym >= 0 && item.ParentNode >= 0) 1501 if (sym >= 0 && item.ParentNode >= 0)
1482 { 1502 {
1483 item.SymLinkItemIndex = FindTargetItem_for_SymLink(item.ParentNode, _symLinks[sym]); 1503 item.SymLinkItemIndex = FindTargetItem_for_SymLink((unsigned)item.ParentNode, _symLinks[sym]);
1484 if (_openCallback) 1504 if (_openCallback)
1485 { 1505 {
1486 complex++; 1506 complex++;
1487 if (complex - prev >= (1 << 10)) 1507 if (complex - prev >= (1 << 10))
1488 { 1508 {
1489 RINOK(CheckProgress2());
1490 prev = complex; 1509 prev = complex;
1510 RINOK(CheckProgress2())
1491 } 1511 }
1492 } 1512 }
1493 } 1513 }
@@ -1502,7 +1522,7 @@ HRESULT CHandler::Open2(IInStream *inStream)
1502 1522
1503 FOR_VECTOR (i, _refs) 1523 FOR_VECTOR (i, _refs)
1504 { 1524 {
1505 int nodeIndex = _refs[i]; 1525 const int nodeIndex = _refs[i];
1506 if (nodeIndex < 0) 1526 if (nodeIndex < 0)
1507 continue; 1527 continue;
1508 const CNode &node = _nodes[nodeIndex]; 1528 const CNode &node = _nodes[nodeIndex];
@@ -1523,7 +1543,7 @@ HRESULT CHandler::Open2(IInStream *inStream)
1523 1543
1524 if (i < _h.FirstInode) 1544 if (i < _h.FirstInode)
1525 { 1545 {
1526 if (item.Node < ARRAY_SIZE(k_SysInode_Names)) 1546 if (item.Node < Z7_ARRAY_SIZE(k_SysInode_Names))
1527 item.Name = k_SysInode_Names[item.Node]; 1547 item.Name = k_SysInode_Names[item.Node];
1528 useSys = true; 1548 useSys = true;
1529 } 1549 }
@@ -1538,16 +1558,16 @@ HRESULT CHandler::Open2(IInStream *inStream)
1538 } 1558 }
1539 1559
1540 if (useSys) 1560 if (useSys)
1541 _auxSysIndex = _auxItems.Add((AString)"[SYS]"); 1561 _auxSysIndex = (int)_auxItems.Add((AString)"[SYS]");
1542 if (useUnknown) 1562 if (useUnknown)
1543 _auxUnknownIndex = _auxItems.Add((AString)"[UNKNOWN]"); 1563 _auxUnknownIndex = (int)_auxItems.Add((AString)"[UNKNOWN]");
1544 } 1564 }
1545 1565
1546 return S_OK; 1566 return S_OK;
1547} 1567}
1548 1568
1549 1569
1550STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *callback) 1570Z7_COM7F_IMF(CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *callback))
1551{ 1571{
1552 COM_TRY_BEGIN 1572 COM_TRY_BEGIN
1553 { 1573 {
@@ -1590,7 +1610,7 @@ void CHandler::ClearRefs()
1590} 1610}
1591 1611
1592 1612
1593STDMETHODIMP CHandler::Close() 1613Z7_COM7F_IMF(CHandler::Close())
1594{ 1614{
1595 _totalRead = 0; 1615 _totalRead = 0;
1596 _totalReadPrev = 0; 1616 _totalReadPrev = 0;
@@ -1652,7 +1672,7 @@ void CHandler::GetPath(unsigned index, AString &s) const
1652 const CNode &node = _nodes[_refs[item.ParentNode]]; 1672 const CNode &node = _nodes[_refs[item.ParentNode]];
1653 if (node.ItemIndex < 0) 1673 if (node.ItemIndex < 0)
1654 return; 1674 return;
1655 index = node.ItemIndex; 1675 index = (unsigned)node.ItemIndex;
1656 1676
1657 if (s.Len() > ((UInt32)1 << 16)) 1677 if (s.Len() > ((UInt32)1 << 16))
1658 { 1678 {
@@ -1707,7 +1727,7 @@ bool CHandler::GetPackSize(unsigned index, UInt64 &totalPack) const
1707} 1727}
1708 1728
1709 1729
1710STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) 1730Z7_COM7F_IMF(CHandler::GetNumberOfItems(UInt32 *numItems))
1711{ 1731{
1712 *numItems = _items.Size() + _auxItems.Size(); 1732 *numItems = _items.Size() + _auxItems.Size();
1713 return S_OK; 1733 return S_OK;
@@ -1797,7 +1817,7 @@ static void UnixTimeToProp(UInt32 val, NCOM::CPropVariant &prop)
1797 PropVariant_SetFrom_UnixTime(prop, val); 1817 PropVariant_SetFrom_UnixTime(prop, val);
1798} 1818}
1799 1819
1800STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) 1820Z7_COM7F_IMF(CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value))
1801{ 1821{
1802 COM_TRY_BEGIN 1822 COM_TRY_BEGIN
1803 1823
@@ -1869,7 +1889,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
1869 case kpidErrorFlags: 1889 case kpidErrorFlags:
1870 { 1890 {
1871 UInt32 v = 0; 1891 UInt32 v = 0;
1872 if (!_isArc) v |= kpv_ErrorFlags_IsNotArc;; 1892 if (!_isArc) v |= kpv_ErrorFlags_IsNotArc;
1873 if (_linksError) v |= kpv_ErrorFlags_HeadersError; 1893 if (_linksError) v |= kpv_ErrorFlags_HeadersError;
1874 if (_headersError) v |= kpv_ErrorFlags_HeadersError; 1894 if (_headersError) v |= kpv_ErrorFlags_HeadersError;
1875 if (!_stream && v == 0 && _isArc) 1895 if (!_stream && v == 0 && _isArc)
@@ -1903,22 +1923,22 @@ static const Byte kRawProps[] =
1903}; 1923};
1904*/ 1924*/
1905 1925
1906STDMETHODIMP CHandler::GetNumRawProps(UInt32 *numProps) 1926Z7_COM7F_IMF(CHandler::GetNumRawProps(UInt32 *numProps))
1907{ 1927{
1908 // *numProps = ARRAY_SIZE(kRawProps); 1928 // *numProps = Z7_ARRAY_SIZE(kRawProps);
1909 *numProps = 0; 1929 *numProps = 0;
1910 return S_OK; 1930 return S_OK;
1911} 1931}
1912 1932
1913STDMETHODIMP CHandler::GetRawPropInfo(UInt32 /* index */, BSTR *name, PROPID *propID) 1933Z7_COM7F_IMF(CHandler::GetRawPropInfo(UInt32 /* index */, BSTR *name, PROPID *propID))
1914{ 1934{
1915 // *propID = kRawProps[index]; 1935 // *propID = kRawProps[index];
1916 *propID = 0; 1936 *propID = 0;
1917 *name = 0; 1937 *name = NULL;
1918 return S_OK; 1938 return S_OK;
1919} 1939}
1920 1940
1921STDMETHODIMP CHandler::GetParent(UInt32 index, UInt32 *parent, UInt32 *parentType) 1941Z7_COM7F_IMF(CHandler::GetParent(UInt32 index, UInt32 *parent, UInt32 *parentType))
1922{ 1942{
1923 *parentType = NParentType::kDir; 1943 *parentType = NParentType::kDir;
1924 *parent = (UInt32)(Int32)-1; 1944 *parent = (UInt32)(Int32)-1;
@@ -1930,22 +1950,22 @@ STDMETHODIMP CHandler::GetParent(UInt32 index, UInt32 *parent, UInt32 *parentTyp
1930 1950
1931 if (item.ParentNode < 0) 1951 if (item.ParentNode < 0)
1932 { 1952 {
1933 int aux = GetParentAux(item); 1953 const int aux = GetParentAux(item);
1934 if (aux >= 0) 1954 if (aux >= 0)
1935 *parent = _items.Size() + aux; 1955 *parent = _items.Size() + (unsigned)aux;
1936 } 1956 }
1937 else 1957 else
1938 { 1958 {
1939 int itemIndex = _nodes[_refs[item.ParentNode]].ItemIndex; 1959 const int itemIndex = _nodes[_refs[item.ParentNode]].ItemIndex;
1940 if (itemIndex >= 0) 1960 if (itemIndex >= 0)
1941 *parent = itemIndex; 1961 *parent = (unsigned)itemIndex;
1942 } 1962 }
1943 1963
1944 return S_OK; 1964 return S_OK;
1945} 1965}
1946 1966
1947 1967
1948STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType) 1968Z7_COM7F_IMF(CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType))
1949{ 1969{
1950 *data = NULL; 1970 *data = NULL;
1951 *dataSize = 0; 1971 *dataSize = 0;
@@ -2017,7 +2037,7 @@ static void ExtTimeToProp(const CExtTime &t, NCOM::CPropVariant &prop)
2017} 2037}
2018 2038
2019 2039
2020STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) 2040Z7_COM7F_IMF(CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value))
2021{ 2041{
2022 COM_TRY_BEGIN 2042 COM_TRY_BEGIN
2023 NCOM::CPropVariant prop; 2043 NCOM::CPropVariant prop;
@@ -2094,7 +2114,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
2094 case kpidPosixAttrib: 2114 case kpidPosixAttrib:
2095 { 2115 {
2096 /* 2116 /*
2097 if (node.Type != 0 && node.Type < ARRAY_SIZE(k_TypeToMode)) 2117 if (node.Type != 0 && node.Type < Z7_ARRAY_SIZE(k_TypeToMode))
2098 prop = (UInt32)(node.Mode & 0xFFF) | k_TypeToMode[node.Type]; 2118 prop = (UInt32)(node.Mode & 0xFFF) | k_TypeToMode[node.Type];
2099 */ 2119 */
2100 prop = (UInt32)(node.Mode); 2120 prop = (UInt32)(node.Mode);
@@ -2137,10 +2157,8 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
2137} 2157}
2138 2158
2139 2159
2140class CClusterInStream2: 2160Z7_CLASS_IMP_IInStream(CClusterInStream2
2141 public IInStream, 2161)
2142 public CMyUnknownImp
2143{
2144 UInt64 _virtPos; 2162 UInt64 _virtPos;
2145 UInt64 _physPos; 2163 UInt64 _physPos;
2146 UInt32 _curRem; 2164 UInt32 _curRem;
@@ -2150,7 +2168,7 @@ public:
2150 CMyComPtr<IInStream> Stream; 2168 CMyComPtr<IInStream> Stream;
2151 CRecordVector<UInt32> Vector; 2169 CRecordVector<UInt32> Vector;
2152 2170
2153 HRESULT SeekToPhys() { return Stream->Seek(_physPos, STREAM_SEEK_SET, NULL); } 2171 HRESULT SeekToPhys() { return InStream_SeekSet(Stream, _physPos); }
2154 2172
2155 HRESULT InitAndSeek() 2173 HRESULT InitAndSeek()
2156 { 2174 {
@@ -2164,15 +2182,10 @@ public:
2164 } 2182 }
2165 return S_OK; 2183 return S_OK;
2166 } 2184 }
2167
2168 MY_UNKNOWN_IMP2(ISequentialInStream, IInStream)
2169
2170 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
2171 STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
2172}; 2185};
2173 2186
2174 2187
2175STDMETHODIMP CClusterInStream2::Read(void *data, UInt32 size, UInt32 *processedSize) 2188Z7_COM7F_IMF(CClusterInStream2::Read(void *data, UInt32 size, UInt32 *processedSize))
2176{ 2189{
2177 if (processedSize) 2190 if (processedSize)
2178 *processedSize = 0; 2191 *processedSize = 0;
@@ -2209,7 +2222,7 @@ STDMETHODIMP CClusterInStream2::Read(void *data, UInt32 size, UInt32 *processedS
2209 if (newPos != _physPos) 2222 if (newPos != _physPos)
2210 { 2223 {
2211 _physPos = newPos; 2224 _physPos = newPos;
2212 RINOK(SeekToPhys()); 2225 RINOK(SeekToPhys())
2213 } 2226 }
2214 2227
2215 _curRem = blockSize - offsetInBlock; 2228 _curRem = blockSize - offsetInBlock;
@@ -2229,7 +2242,7 @@ STDMETHODIMP CClusterInStream2::Read(void *data, UInt32 size, UInt32 *processedS
2229 return res; 2242 return res;
2230} 2243}
2231 2244
2232STDMETHODIMP CClusterInStream2::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) 2245Z7_COM7F_IMF(CClusterInStream2::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition))
2233{ 2246{
2234 switch (seekOrigin) 2247 switch (seekOrigin)
2235 { 2248 {
@@ -2242,17 +2255,16 @@ STDMETHODIMP CClusterInStream2::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *ne
2242 return HRESULT_WIN32_ERROR_NEGATIVE_SEEK; 2255 return HRESULT_WIN32_ERROR_NEGATIVE_SEEK;
2243 if (_virtPos != (UInt64)offset) 2256 if (_virtPos != (UInt64)offset)
2244 _curRem = 0; 2257 _curRem = 0;
2245 _virtPos = offset; 2258 _virtPos = (UInt64)offset;
2246 if (newPosition) 2259 if (newPosition)
2247 *newPosition = offset; 2260 *newPosition = (UInt64)offset;
2248 return S_OK; 2261 return S_OK;
2249} 2262}
2250 2263
2251 2264
2252class CExtInStream: 2265Z7_CLASS_IMP_IInStream(
2253 public IInStream, 2266 CExtInStream
2254 public CMyUnknownImp 2267)
2255{
2256 UInt64 _virtPos; 2268 UInt64 _virtPos;
2257 UInt64 _phyPos; 2269 UInt64 _phyPos;
2258public: 2270public:
@@ -2261,21 +2273,15 @@ public:
2261 CMyComPtr<IInStream> Stream; 2273 CMyComPtr<IInStream> Stream;
2262 CRecordVector<CExtent> Extents; 2274 CRecordVector<CExtent> Extents;
2263 2275
2264 CExtInStream() {}
2265
2266 HRESULT StartSeek() 2276 HRESULT StartSeek()
2267 { 2277 {
2268 _virtPos = 0; 2278 _virtPos = 0;
2269 _phyPos = 0; 2279 _phyPos = 0;
2270 return Stream->Seek(_phyPos, STREAM_SEEK_SET, NULL); 2280 return InStream_SeekSet(Stream, _phyPos);
2271 } 2281 }
2272
2273 MY_UNKNOWN_IMP2(ISequentialInStream, IInStream)
2274 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
2275 STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
2276}; 2282};
2277 2283
2278STDMETHODIMP CExtInStream::Read(void *data, UInt32 size, UInt32 *processedSize) 2284Z7_COM7F_IMF(CExtInStream::Read(void *data, UInt32 size, UInt32 *processedSize))
2279{ 2285{
2280 if (processedSize) 2286 if (processedSize)
2281 *processedSize = 0; 2287 *processedSize = 0;
@@ -2328,18 +2334,18 @@ STDMETHODIMP CExtInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
2328 return S_OK; 2334 return S_OK;
2329 } 2335 }
2330 2336
2331 UInt64 phyBlock = extent.PhyStart + bo; 2337 const UInt64 phyBlock = extent.PhyStart + bo;
2332 UInt64 phy = (phyBlock << BlockBits) + offset; 2338 const UInt64 phy = (phyBlock << BlockBits) + offset;
2333 2339
2334 if (phy != _phyPos) 2340 if (phy != _phyPos)
2335 { 2341 {
2336 RINOK(Stream->Seek(phy, STREAM_SEEK_SET, NULL)); 2342 RINOK(InStream_SeekSet(Stream, phy))
2337 _phyPos = phy; 2343 _phyPos = phy;
2338 } 2344 }
2339 2345
2340 UInt32 realProcessSize = 0; 2346 UInt32 realProcessSize = 0;
2341 2347
2342 HRESULT res = Stream->Read(data, size, &realProcessSize); 2348 const HRESULT res = Stream->Read(data, size, &realProcessSize);
2343 2349
2344 _phyPos += realProcessSize; 2350 _phyPos += realProcessSize;
2345 _virtPos += realProcessSize; 2351 _virtPos += realProcessSize;
@@ -2350,7 +2356,7 @@ STDMETHODIMP CExtInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
2350} 2356}
2351 2357
2352 2358
2353STDMETHODIMP CExtInStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) 2359Z7_COM7F_IMF(CExtInStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition))
2354{ 2360{
2355 switch (seekOrigin) 2361 switch (seekOrigin)
2356 { 2362 {
@@ -2361,9 +2367,9 @@ STDMETHODIMP CExtInStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosi
2361 } 2367 }
2362 if (offset < 0) 2368 if (offset < 0)
2363 return HRESULT_WIN32_ERROR_NEGATIVE_SEEK; 2369 return HRESULT_WIN32_ERROR_NEGATIVE_SEEK;
2364 _virtPos = offset; 2370 _virtPos = (UInt64)offset;
2365 if (newPosition) 2371 if (newPosition)
2366 *newPosition = offset; 2372 *newPosition = (UInt64)offset;
2367 return S_OK; 2373 return S_OK;
2368} 2374}
2369 2375
@@ -2377,7 +2383,7 @@ HRESULT CHandler::FillFileBlocks2(UInt32 block, unsigned level, unsigned numBloc
2377 2383
2378 PRF2(printf("\n level = %d, block = %7d", level, (unsigned)block)); 2384 PRF2(printf("\n level = %d, block = %7d", level, (unsigned)block));
2379 2385
2380 RINOK(SeekAndRead(_stream, block, tempBuf, blockSize)); 2386 RINOK(SeekAndRead(_stream, block, tempBuf, blockSize))
2381 2387
2382 const Byte *p = tempBuf; 2388 const Byte *p = tempBuf;
2383 size_t num = (size_t)1 << (_h.BlockBits - 2); 2389 size_t num = (size_t)1 << (_h.BlockBits - 2);
@@ -2408,7 +2414,7 @@ HRESULT CHandler::FillFileBlocks2(UInt32 block, unsigned level, unsigned numBloc
2408 return S_FALSE; 2414 return S_FALSE;
2409 } 2415 }
2410 2416
2411 RINOK(FillFileBlocks2(val, level - 1, numBlocks, blocks)); 2417 RINOK(FillFileBlocks2(val, level - 1, numBlocks, blocks))
2412 continue; 2418 continue;
2413 } 2419 }
2414 2420
@@ -2464,7 +2470,7 @@ HRESULT CHandler::FillFileBlocks(const Byte *p, unsigned numBlocks, CRecordVecto
2464 return S_FALSE; 2470 return S_FALSE;
2465 } 2471 }
2466 2472
2467 RINOK(FillFileBlocks2(val, level, numBlocks, blocks)); 2473 RINOK(FillFileBlocks2(val, level, numBlocks, blocks))
2468 } 2474 }
2469 2475
2470 return S_OK; 2476 return S_OK;
@@ -2560,8 +2566,8 @@ HRESULT CHandler::FillExtents(const Byte *p, size_t size, CRecordVector<CExtent>
2560 if (!UpdateExtents(extents, e.VirtBlock)) 2566 if (!UpdateExtents(extents, e.VirtBlock))
2561 return S_FALSE; 2567 return S_FALSE;
2562 2568
2563 RINOK(SeekAndRead(_stream, e.PhyLeaf, tempBuf, blockSize)); 2569 RINOK(SeekAndRead(_stream, e.PhyLeaf, tempBuf, blockSize))
2564 RINOK(FillExtents(tempBuf, blockSize, extents, eth.Depth)); 2570 RINOK(FillExtents(tempBuf, blockSize, extents, eth.Depth))
2565 } 2571 }
2566 2572
2567 return S_OK; 2573 return S_OK;
@@ -2610,7 +2616,7 @@ HRESULT CHandler::GetStream_Node(unsigned nodeIndex, ISequentialInStream **strea
2610 streamSpec->Size = node.FileSize; 2616 streamSpec->Size = node.FileSize;
2611 streamSpec->Stream = _stream; 2617 streamSpec->Stream = _stream;
2612 2618
2613 RINOK(FillExtents(node.Block, kNodeBlockFieldSize, streamSpec->Extents, -1)); 2619 RINOK(FillExtents(node.Block, kNodeBlockFieldSize, streamSpec->Extents, -1))
2614 2620
2615 UInt32 end = 0; 2621 UInt32 end = 0;
2616 if (!streamSpec->Extents.IsEmpty()) 2622 if (!streamSpec->Extents.IsEmpty())
@@ -2621,7 +2627,7 @@ HRESULT CHandler::GetStream_Node(unsigned nodeIndex, ISequentialInStream **strea
2621 // return S_FALSE; 2627 // return S_FALSE;
2622 } 2628 }
2623 2629
2624 RINOK(streamSpec->StartSeek()); 2630 RINOK(streamSpec->StartSeek())
2625 } 2631 }
2626 else 2632 else
2627 { 2633 {
@@ -2648,7 +2654,7 @@ HRESULT CHandler::GetStream_Node(unsigned nodeIndex, ISequentialInStream **strea
2648 } 2654 }
2649 2655
2650 const unsigned specBits = (node.IsFlags_HUGE() ? 0 : _h.BlockBits - 9); 2656 const unsigned specBits = (node.IsFlags_HUGE() ? 0 : _h.BlockBits - 9);
2651 const UInt32 specMask = ((UInt32)1 << specBits) - 1;; 2657 const UInt32 specMask = ((UInt32)1 << specBits) - 1;
2652 if ((node.NumBlocks & specMask) != 0) 2658 if ((node.NumBlocks & specMask) != 0)
2653 return S_FALSE; 2659 return S_FALSE;
2654 const UInt64 numBlocks64_from_header = node.NumBlocks >> specBits; 2660 const UInt64 numBlocks64_from_header = node.NumBlocks >> specBits;
@@ -2670,7 +2676,7 @@ HRESULT CHandler::GetStream_Node(unsigned nodeIndex, ISequentialInStream **strea
2670 streamSpec->Size = node.FileSize; 2676 streamSpec->Size = node.FileSize;
2671 streamSpec->Stream = _stream; 2677 streamSpec->Stream = _stream;
2672 2678
2673 RINOK(FillFileBlocks(node.Block, numBlocks, streamSpec->Vector)); 2679 RINOK(FillFileBlocks(node.Block, numBlocks, streamSpec->Vector))
2674 streamSpec->InitAndSeek(); 2680 streamSpec->InitAndSeek();
2675 } 2681 }
2676 2682
@@ -2690,7 +2696,7 @@ HRESULT CHandler::ExtractNode(unsigned nodeIndex, CByteBuffer &data)
2690 if (size != node.FileSize) 2696 if (size != node.FileSize)
2691 return S_FALSE; 2697 return S_FALSE;
2692 CMyComPtr<ISequentialInStream> inSeqStream; 2698 CMyComPtr<ISequentialInStream> inSeqStream;
2693 RINOK(GetStream_Node(nodeIndex, &inSeqStream)); 2699 RINOK(GetStream_Node(nodeIndex, &inSeqStream))
2694 if (!inSeqStream) 2700 if (!inSeqStream)
2695 return S_FALSE; 2701 return S_FALSE;
2696 data.Alloc(size); 2702 data.Alloc(size);
@@ -2699,11 +2705,11 @@ HRESULT CHandler::ExtractNode(unsigned nodeIndex, CByteBuffer &data)
2699} 2705}
2700 2706
2701 2707
2702STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, 2708Z7_COM7F_IMF(CHandler::Extract(const UInt32 *indices, UInt32 numItems,
2703 Int32 testMode, IArchiveExtractCallback *extractCallback) 2709 Int32 testMode, IArchiveExtractCallback *extractCallback))
2704{ 2710{
2705 COM_TRY_BEGIN 2711 COM_TRY_BEGIN
2706 bool allFilesMode = (numItems == (UInt32)(Int32)-1); 2712 const bool allFilesMode = (numItems == (UInt32)(Int32)-1);
2707 if (allFilesMode) 2713 if (allFilesMode)
2708 numItems = _items.Size() + _auxItems.Size(); 2714 numItems = _items.Size() + _auxItems.Size();
2709 if (numItems == 0) 2715 if (numItems == 0)
@@ -2714,7 +2720,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
2714 2720
2715 for (i = 0; i < numItems; i++) 2721 for (i = 0; i < numItems; i++)
2716 { 2722 {
2717 UInt32 index = allFilesMode ? i : indices[i]; 2723 const UInt32 index = allFilesMode ? i : indices[i];
2718 if (index >= _items.Size()) 2724 if (index >= _items.Size())
2719 continue; 2725 continue;
2720 const CItem &item = _items[index]; 2726 const CItem &item = _items[index];
@@ -2739,24 +2745,24 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
2739 { 2745 {
2740 lps->InSize = totalPackSize; 2746 lps->InSize = totalPackSize;
2741 lps->OutSize = totalSize; 2747 lps->OutSize = totalSize;
2742 RINOK(lps->SetCur()); 2748 RINOK(lps->SetCur())
2743 2749
2744 if (i == numItems) 2750 if (i == numItems)
2745 break; 2751 break;
2746 2752
2747 CMyComPtr<ISequentialOutStream> outStream; 2753 CMyComPtr<ISequentialOutStream> outStream;
2748 Int32 askMode = testMode ? 2754 const Int32 askMode = testMode ?
2749 NExtract::NAskMode::kTest : 2755 NExtract::NAskMode::kTest :
2750 NExtract::NAskMode::kExtract; 2756 NExtract::NAskMode::kExtract;
2751 2757
2752 UInt32 index = allFilesMode ? i : indices[i]; 2758 const UInt32 index = allFilesMode ? i : indices[i];
2753 2759
2754 RINOK(extractCallback->GetStream(index, &outStream, askMode)); 2760 RINOK(extractCallback->GetStream(index, &outStream, askMode))
2755 2761
2756 if (index >= _items.Size()) 2762 if (index >= _items.Size())
2757 { 2763 {
2758 RINOK(extractCallback->PrepareOperation(askMode)); 2764 RINOK(extractCallback->PrepareOperation(askMode))
2759 RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); 2765 RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK))
2760 continue; 2766 continue;
2761 } 2767 }
2762 2768
@@ -2765,8 +2771,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
2765 2771
2766 if (node.IsDir()) 2772 if (node.IsDir())
2767 { 2773 {
2768 RINOK(extractCallback->PrepareOperation(askMode)); 2774 RINOK(extractCallback->PrepareOperation(askMode))
2769 RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); 2775 RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK))
2770 continue; 2776 continue;
2771 } 2777 }
2772 2778
@@ -2778,7 +2784,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
2778 2784
2779 if (!testMode && !outStream) 2785 if (!testMode && !outStream)
2780 continue; 2786 continue;
2781 RINOK(extractCallback->PrepareOperation(askMode)); 2787 RINOK(extractCallback->PrepareOperation(askMode))
2782 2788
2783 int res = NExtract::NOperationResult::kDataError; 2789 int res = NExtract::NOperationResult::kDataError;
2784 { 2790 {
@@ -2792,7 +2798,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
2792 } 2798 }
2793 else 2799 else
2794 { 2800 {
2795 RINOK(hres); 2801 RINOK(hres)
2796 { 2802 {
2797 hres = copyCoder->Code(inSeqStream, outStream, NULL, NULL, progress); 2803 hres = copyCoder->Code(inSeqStream, outStream, NULL, NULL, progress);
2798 if (hres == S_OK) 2804 if (hres == S_OK)
@@ -2806,12 +2812,12 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
2806 } 2812 }
2807 else if (hres != S_FALSE) 2813 else if (hres != S_FALSE)
2808 { 2814 {
2809 RINOK(hres); 2815 RINOK(hres)
2810 } 2816 }
2811 } 2817 }
2812 } 2818 }
2813 } 2819 }
2814 RINOK(extractCallback->SetOperationResult(res)); 2820 RINOK(extractCallback->SetOperationResult(res))
2815 } 2821 }
2816 2822
2817 return S_OK; 2823 return S_OK;
@@ -2819,12 +2825,12 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
2819} 2825}
2820 2826
2821 2827
2822STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream) 2828Z7_COM7F_IMF(CHandler::GetStream(UInt32 index, ISequentialInStream **stream))
2823{ 2829{
2824 *stream = NULL; 2830 *stream = NULL;
2825 if (index >= _items.Size()) 2831 if (index >= _items.Size())
2826 return S_FALSE; 2832 return S_FALSE;
2827 return GetStream_Node(_refs[_items[index].Node], stream); 2833 return GetStream_Node((unsigned)_refs[_items[index].Node], stream);
2828} 2834}
2829 2835
2830 2836
@@ -2854,7 +2860,7 @@ API_FUNC_IsArc IsArc_Ext(const Byte *p, size_t size)
2854static const Byte k_Signature[] = { 0x53, 0xEF }; 2860static const Byte k_Signature[] = { 0x53, 0xEF };
2855 2861
2856REGISTER_ARC_I( 2862REGISTER_ARC_I(
2857 "Ext", "ext ext2 ext3 ext4 img", 0, 0xC7, 2863 "Ext", "ext ext2 ext3 ext4 img", NULL, 0xC7,
2858 k_Signature, 2864 k_Signature,
2859 0x438, 2865 0x438,
2860 0, 2866 0,