MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / ReadEntireFile

Function ReadEntireFile

tests/gtest/gtest-all.cc:10920–10940  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10918}
10919
10920std::string ReadEntireFile(FILE* file) {
10921 const size_t file_size = GetFileSize(file);
10922 char* const buffer = new char[file_size];
10923
10924 size_t bytes_last_read = 0; // # of bytes read in the last fread()
10925 size_t bytes_read = 0; // # of bytes read so far
10926
10927 fseek(file, 0, SEEK_SET);
10928
10929 // Keeps reading the file until we cannot read further or the
10930 // pre-determined file size is reached.
10931 do {
10932 bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file);
10933 bytes_read += bytes_last_read;
10934 } while (bytes_last_read > 0 && bytes_read < file_size);
10935
10936 const std::string content(buffer, bytes_read);
10937 delete[] buffer;
10938
10939 return content;
10940}
10941
10942#if GTEST_HAS_DEATH_TEST
10943static const std::vector<std::string>* g_injected_test_argvs =

Callers 2

LoadFlagsFromFileFunction · 0.85
GetCapturedStringMethod · 0.85

Calls 1

GetFileSizeFunction · 0.85

Tested by

no test coverage detected