Spaces:
Runtime error
Runtime error
Download include/CL/Utils/File.hpp from faisalhr1997/Koboldcpp: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/spaces/faisalhr1997/Koboldcpp/resolve/main/include/CL/Utils/File.hpp
- Command line
-
hf download hf://spaces/faisalhr1997/Koboldcpp/include/CL/Utils/File.hpp
-
curl -L -o File.hpp https://huggingface.co/spaces/faisalhr1997/Koboldcpp/resolve/main/include/CL/Utils/File.hpp
1.39 kB
| // OpenCL SDK includes | |
| // STL includes | |
| namespace cl { | |
| namespace util { | |
| // Scott Meyers, Effective STL, Addison-Wesley Professional, 2001, Item 29 | |
| // with error handling | |
| UTILSCPP_EXPORT | |
| std::string read_text_file(const char* const filename, cl_int* const error) | |
| { | |
| std::ifstream in(filename); | |
| if (in.good()) | |
| { | |
| try | |
| { | |
| std::string red((std::istreambuf_iterator<char>(in)), | |
| std::istreambuf_iterator<char>()); | |
| if (in.good() && in.eof()) | |
| { | |
| if (error != nullptr) *error = CL_SUCCESS; | |
| return red; | |
| } | |
| else | |
| { | |
| detail::errHandler(CL_UTIL_FILE_OPERATION_ERROR, error, | |
| "File read error!"); | |
| return std::string(); | |
| } | |
| } catch (std::bad_alloc& ex) | |
| { | |
| detail::errHandler(CL_OUT_OF_RESOURCES, error, | |
| "Bad allocation!"); | |
| return std::string(); | |
| } | |
| } | |
| else | |
| { | |
| detail::errHandler(CL_INVALID_VALUE, error, "No file!"); | |
| return std::string(); | |
| } | |
| } | |
| } | |
| } | |