MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / readAll

Method readAll

framework/physfs_fs.cpp:196–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196std::unique_ptr<char[]> IFile::readAll()
197{
198 auto memsize = this->size();
199 std::unique_ptr<char[]> mem(new char[memsize]);
200 if (!mem)
201 {
202 LogError("Failed to allocate memory for %llu bytes",
203 static_cast<long long unsigned>(memsize));
204 return nullptr;
205 }
206
207 // We don't want this to change the state (such as the offset) of the file
208 // stream so store off the current pos and restore it after the read
209 auto currentPos = this->tellg();
210 this->seekg(0, this->beg);
211
212 this->read(mem.get(), memsize);
213
214 this->seekg(currentPos);
215
216 return mem;
217}
218
219IFile::~IFile() = default;
220

Callers 11

UFO2PMethod · 0.80
TACPMethod · 0.80
loadPlaylistsMethod · 0.80
readAliasFileMethod · 0.80
loadImageMethod · 0.80
loadPNGPaletteMethod · 0.80
loadImageMethod · 0.80
readPckCompression3Function · 0.80
loadFontMethod · 0.80
loadMethod · 0.80
loadFormMethod · 0.80

Calls 3

sizeMethod · 0.95
readMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected