MCPcopy Create free account
hub / github.com/NetSPI/BOF-PE / ReadFileAsString

Function ReadFileAsString

common/standalone.cpp:66–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66auto ReadFileAsString(std::string_view path) -> std::string {
67 constexpr auto read_size = std::size_t(65536);
68 auto stream = std::ifstream(path.data());
69 stream.exceptions(std::ios_base::badbit);
70
71 if (!stream) {
72 throw std::ios_base::failure("file does not exist");
73 }
74
75 auto out = std::string();
76 auto buf = std::string(read_size, '\0');
77 while (stream.read(&buf[0], read_size)) {
78 out.append(buf, 0, stream.gcount());
79 }
80 out.append(buf, 0, stream.gcount());
81 return out;
82}
83
84static ByteArray ReadFileData(const std::string& file) {
85

Callers 1

GetPackedArgumentsFunction · 0.85

Calls 3

exceptionsMethod · 0.80
dataMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected