MCPcopy Create free account
hub / github.com/HexHive/NASS / FileToVector

Function FileToVector

fuzz/libfuzzer/FuzzerIO.cpp:41–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41Unit FileToVector(const std::string &Path, size_t MaxSize, bool ExitOnError) {
42 std::ifstream T(Path, std::ios::binary);
43 if (ExitOnError && !T) {
44 Printf("No such directory: %s; exiting\n", Path.c_str());
45 exit(1);
46 }
47
48 T.seekg(0, T.end);
49 auto EndPos = T.tellg();
50 if (EndPos < 0) return {};
51 size_t FileLen = EndPos;
52 if (MaxSize)
53 FileLen = std::min(FileLen, MaxSize);
54
55 T.seekg(0, T.beg);
56 Unit Res(FileLen);
57 T.read(reinterpret_cast<char *>(Res.data()), FileLen);
58 return Res;
59}
60
61std::string FileToString(const std::string &Path) {
62 std::ifstream T(Path, std::ios::binary);

Callers 12

ReadDirToVectorOfUnitsFunction · 0.85
RunOneTestFunction · 0.85
CleanseCrashInputFunction · 0.85
MinimizeCrashInputFunction · 0.85
MergeFunction · 0.85
LoopMethod · 0.85
RunOneMergeJobMethod · 0.85
InitMethod · 0.85
CollectDataFlowFunction · 0.85

Calls 4

PrintfFunction · 0.70
c_strMethod · 0.45
readMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected