18 FILE* file = fopen(filename,
"rb");
20 fprintf(stderr,
"Failed to open: %s\n", filename);
23 (
void)fseek(file, 0, SEEK_END);
24 size_t file_length = ftell(file);
28 (
void)fseek(file, 0, SEEK_SET);
29 std::vector<uint8_t> buffer(file_length);
30 size_t bytes_read = fread(buffer.data(), 1, file_length, file);
32 if (bytes_read != file_length) {
33 fprintf(stderr,
"Failed to read: %s\n", filename);
39FileAccessForTesting::FileAccessForTesting(
const std::string& file_name) {
40 std::string file_path = PathService::GetTestFilePath(file_name);
41 if (file_path.empty()) {
45 file_contents_ = GetFileContents(file_path.c_str());
46 if (file_contents_.empty()) {
50 m_FileLen = pdfium::checked_cast<
unsigned long>(file_contents_.size());
51 m_GetBlock = SGetBlock;