MCPcopy Create free account
hub / github.com/KhronosGroup/glTF-IBL-Sampler / readFile

Method readFile

lib/source/FileHelper.cpp:4–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include <stdio.h>
3
4bool IBLLib::readFile(const char* _path, std::vector<char>& _outBuffer)
5{
6 FILE* file = fopen(_path, "rb");
7
8 if (file == nullptr)
9 {
10 printf("Failed to open file %s\n", _path);
11 return false;
12 }
13
14 // obtain file size:
15 fseek(file, 0, SEEK_END);
16 auto size = ftell(file);
17 rewind(file);
18
19 _outBuffer.resize(size);
20
21 // read the file
22 auto sizeRead = fread(_outBuffer.data(), sizeof(char), size, file);
23 fclose(file);
24
25 return sizeRead > 0u;
26}
27
28bool IBLLib::writeFile(const char* _path, const char* _data, size_t _bytes)
29{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected