MCPcopy Create free account
hub / github.com/bamlab/flashlight / readFile

Function readFile

packages/platforms/android/cpp-profiler/src/utils.cpp:63–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61#define BUFFER_SIZE 2048
62
63void readFile(std::string_view path)
64{
65 constexpr auto read_size = std::size_t(BUFFER_SIZE);
66 auto stream = std::ifstream(path.data());
67 stream.exceptions(std::ios_base::badbit);
68
69 if (not stream)
70 {
71 std::cerr << "CPP_ERROR_CANNOT_OPEN_FILE " << path << "\n";
72 return;
73 }
74
75 auto out = std::string();
76 auto buf = std::string(read_size, '\0');
77 while (stream.read(&buf[0], read_size))
78 {
79 out.append(buf, 0, stream.gcount());
80 }
81 out.append(buf, 0, stream.gcount());
82
83 log(out);
84}

Callers 2

printCpuStatsFunction · 0.85
printMemoryStatsFunction · 0.85

Calls 1

logFunction · 0.70

Tested by

no test coverage detected