| 39 | } |
| 40 | |
| 41 | std::vector<unsigned char> |
| 42 | cl::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 | |
| 68 | cl::Program::Binaries |
nothing calls this directly
no outgoing calls
no test coverage detected