* Get resource data into a supplied buffer. * @param filename Name of the file to get. * @param buffer Buffer to use as target storage. * @param n Size of the supplied buffer. * @return Whether the requested resource could be loaded (copied) into the supplied buffer. */
| 81 | * @return Whether the requested resource could be loaded (copied) into the supplied buffer. |
| 82 | */ |
| 83 | bool loadBufferFromResources(const std::string &filename, unsigned char *buffer, const size_t n) |
| 84 | { |
| 85 | size_t length = 0; |
| 86 | const unsigned char *data = NULL; |
| 87 | |
| 88 | if(!loadResource(filename, &data, &length)) |
| 89 | { |
| 90 | LOG_ERROR << "failed to load resource: " << filename; |
| 91 | return false; |
| 92 | } |
| 93 | |
| 94 | if(length != n) |
| 95 | { |
| 96 | LOG_ERROR << "wrong size of resource: " << filename; |
| 97 | return false; |
| 98 | } |
| 99 | |
| 100 | memcpy(buffer, data, length); |
| 101 | return true; |
| 102 | } |
| 103 | |
| 104 | } /* namespace libfreenect2 */ |
nothing calls this directly
no test coverage detected