| 663 | //========================================================================== |
| 664 | |
| 665 | FileReader FResourceFile::GetEntryReader(uint32_t entry, int readertype, int readerflags) |
| 666 | { |
| 667 | FileReader fr; |
| 668 | if (entry < NumLumps) |
| 669 | { |
| 670 | if (Entries[entry].Flags & RESFF_NEEDFILESTART) |
| 671 | { |
| 672 | SetEntryAddress(entry); |
| 673 | } |
| 674 | if (!(Entries[entry].Flags & RESFF_COMPRESSED)) |
| 675 | { |
| 676 | auto buf = Reader.GetBuffer(); |
| 677 | // if this is backed by a memory buffer, create a new reader directly referencing it. |
| 678 | if (buf != nullptr) |
| 679 | { |
| 680 | fr.OpenMemory(buf + Entries[entry].Position, Entries[entry].Length); |
| 681 | } |
| 682 | else |
| 683 | { |
| 684 | if (readertype == READER_SHARED && !mainThread) |
| 685 | readertype = READER_NEW; |
| 686 | if (readertype == READER_SHARED) |
| 687 | { |
| 688 | fr.OpenFilePart(Reader, Entries[entry].Position, Entries[entry].Length); |
| 689 | } |
| 690 | else if (readertype == READER_NEW) |
| 691 | { |
| 692 | fr.OpenFile(FileName, Entries[entry].Position, Entries[entry].Length); |
| 693 | } |
| 694 | else if (readertype == READER_CACHED) |
| 695 | { |
| 696 | Reader.Seek(Entries[entry].Position, FileReader::SeekSet); |
| 697 | auto data = Reader.Read(Entries[entry].Length); |
| 698 | fr.OpenMemoryArray(data); |
| 699 | } |
| 700 | } |
| 701 | } |
| 702 | else |
| 703 | { |
| 704 | FileReader fri; |
| 705 | if (readertype == READER_NEW || !mainThread) fri.OpenFile(FileName, Entries[entry].Position, Entries[entry].CompressedSize); |
| 706 | else fri.OpenFilePart(Reader, Entries[entry].Position, Entries[entry].CompressedSize); |
| 707 | int flags = DCF_TRANSFEROWNER | DCF_EXCEPTIONS; |
| 708 | if (readertype == READER_CACHED) flags |= DCF_CACHED; |
| 709 | else if (readerflags & READERFLAG_SEEKABLE) flags |= DCF_SEEKABLE; |
| 710 | OpenDecompressor(fr, fri, Entries[entry].Length, Entries[entry].Method, flags); |
| 711 | } |
| 712 | } |
| 713 | return fr; |
| 714 | } |
| 715 | |
| 716 | FileData FResourceFile::Read(uint32_t entry) |
| 717 | { |
nothing calls this directly
no test coverage detected