MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / FileRead

Method FileRead

Source/ResourceMan.cpp:348–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346}
347
348tSharedBuffer cResourceMan::FileRead(const std::string& pFile) {
349 std::ifstream* fileStream;
350 auto fileBuffer = std::make_shared<std::vector<uint8_t>>();
351
352 // Attempt to open the file
353 fileStream = new std::ifstream(pFile.c_str(), std::ios::binary);
354 if (fileStream->is_open() != false) {
355
356 // Get file size
357 fileStream->seekg(0, std::ios::end);
358 fileBuffer->resize(static_cast<const unsigned int>(fileStream->tellg()));
359 fileStream->seekg(std::ios::beg);
360
361 // Allocate buffer, and read the file into it
362 fileStream->read((char*)fileBuffer->data(), fileBuffer->size());
363 if (!(*fileStream))
364 fileBuffer->clear();
365 }
366
367 // Close the stream
368 fileStream->close();
369 delete fileStream;
370
371 // All done ;)
372 return fileBuffer;
373}
374
375std::string cResourceMan::GetCampaignData(const std::string& pName) {
376 for (auto& Campaign : mCampaigns) {

Callers 5

fileGetMethod · 0.80
Game_Load_FilterMethod · 0.80
getMapMethod · 0.80
getSpritesMethod · 0.80
cResource_PC_CDMethod · 0.80

Calls 5

resizeMethod · 0.80
closeMethod · 0.80
readMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected