MCPcopy Create free account
hub / github.com/apple/foundationdb / readFileBytes

Function readFileBytes

flow/Platform.actor.cpp:2949–2968  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2947}
2948
2949size_t readFileBytes(std::string const& filename, uint8_t* buff, size_t len) {
2950 std::fstream ifs(filename, std::fstream::in | std::fstream::binary);
2951 if (!ifs.good()) {
2952 TraceEvent("ileBytes_FileOpenError").detail("Filename", filename).GetLastError();
2953 throw io_error();
2954 }
2955
2956 size_t bytesRead = len;
2957 ifs.seekg(0, std::fstream::beg);
2958 ifs.read((char*)buff, len);
2959 if (!ifs) {
2960 bytesRead = ifs.gcount();
2961 TraceEvent("ReadFileBytes_ShortRead")
2962 .detail("Filename", filename)
2963 .detail("Requested", len)
2964 .detail("Actual", bytesRead);
2965 }
2966
2967 return bytesRead;
2968}
2969
2970std::string readFileBytes(std::string const& filename, int maxSize) {
2971 if (!fileExists(filename)) {

Callers 8

readMethod · 0.85
loadSyncMethod · 0.85
printStatusFromJSONFunction · 0.85
getCCPriorityInfoFunction · 0.85
parseArgsInternalMethod · 0.85
loadPublicKeyFileMethod · 0.85
ClusterConnectionFileMethod · 0.85

Calls 7

TraceEventClass · 0.85
fileExistsFunction · 0.85
fileSizeFunction · 0.85
detailMethod · 0.80
readMethod · 0.65
resizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected