MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCL-SDK / read_binary_file

Method read_binary_file

lib/src/Utils/File.cpp:41–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41std::vector<unsigned char>
42cl::util::read_binary_file(const char* const filename, cl_int* const error)
43{
44 std::ifstream in(filename, std::ios::binary);
45 if (in.good())
46 {
47 try
48 {
49 std::vector<unsigned char> buffer(
50 std::istreambuf_iterator<char>(in), {});
51 if (error != nullptr) *error = CL_SUCCESS;
52 return buffer;
53 } catch (std::bad_alloc&)
54 {
55 detail::errHandler(CL_OUT_OF_RESOURCES, error, "Bad allocation!");
56 return std::vector<unsigned char>();
57 }
58 }
59 else
60 {
61 detail::errHandler(CL_UTIL_FILE_OPERATION_ERROR, error,
62 (std::string("Unable to read ") + filename).c_str());
63 return std::vector<unsigned char>();
64 }
65}
66
67
68cl::Program::Binaries

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected