MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / Load

Method Load

Libraries/unrar/qopen.cpp:62–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60
61
62void QuickOpen::Load(uint64 BlockPos)
63{
64 if (!Loaded)
65 {
66 // If loading for the first time, perform additional intialization.
67 SeekPos=Arc->Tell();
68 UnsyncSeekPos=false;
69
70 int64 SavePos=SeekPos;
71 Arc->Seek(BlockPos,SEEK_SET);
72
73 // If BlockPos points to original main header, we'll have the infinite
74 // recursion, because ReadHeader() for main header will attempt to load
75 // QOpen and call QuickOpen::Load again. If BlockPos points to long chain
76 // of other main headers, we'll have multiple recursive calls of this
77 // function wasting resources. So we prohibit QOpen temporarily to
78 // prevent this. ReadHeader() calls QOpen.Init and sets MainHead Locator
79 // and QOpenOffset fields, so we cannot use them to prohibit QOpen.
80 Arc->SetProhibitQOpen(true);
81 size_t ReadSize=Arc->ReadHeader();
82 Arc->SetProhibitQOpen(false);
83
84 if (ReadSize==0 || Arc->GetHeaderType()!=HEAD_SERVICE ||
85 !Arc->SubHead.CmpName(SUBHEAD_TYPE_QOPEN))
86 {
87 Arc->Seek(SavePos,SEEK_SET);
88 return;
89 }
90 QOHeaderPos=Arc->CurBlockPos;
91 RawDataStart=Arc->Tell();
92 RawDataSize=Arc->SubHead.UnpSize;
93 Arc->Seek(SavePos,SEEK_SET);
94
95 Loaded=true; // Set only after all file processing calls like Tell, Seek, ReadHeader.
96 }
97
98 if (Arc->SubHead.Encrypted)
99 {
100 RAROptions *Cmd=Arc->GetRAROptions();
101#ifndef RAR_NOCRYPT
102 if (Cmd->Password.IsSet())
103 Crypt.SetCryptKeys(false,CRYPT_RAR50,&Cmd->Password,Arc->SubHead.Salt,
104 Arc->SubHead.InitV,Arc->SubHead.Lg2Count,
105 Arc->SubHead.HashKey,Arc->SubHead.PswCheck);
106 else
107#endif
108 {
109 Loaded=false;
110 return;
111 }
112 }
113
114 RawDataPos=0;
115 ReadBufSize=0;
116 ReadBufPos=0;
117 LastReadHeader.Reset();
118 LastReadHeaderPos=0;
119

Callers 1

ReadHeader50Method · 0.45

Calls 10

SetProhibitQOpenMethod · 0.80
GetHeaderTypeMethod · 0.80
CmpNameMethod · 0.80
GetRAROptionsMethod · 0.80
SetCryptKeysMethod · 0.80
TellMethod · 0.45
SeekMethod · 0.45
ReadHeaderMethod · 0.45
IsSetMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected