--------------------------------------------------------------------* * Read and write between file and memory * *--------------------------------------------------------------------*/ ! * \brief l_binaryRead() * * \param[in] filename * \param[out] pnbytes number of bytes read * \return data, or NULL on error */
| 1151 | * \return data, or NULL on error |
| 1152 | */ |
| 1153 | l_uint8 * |
| 1154 | l_binaryRead(const char *filename, |
| 1155 | size_t *pnbytes) |
| 1156 | { |
| 1157 | l_uint8 *data; |
| 1158 | FILE *fp; |
| 1159 | |
| 1160 | PROCNAME("l_binaryRead"); |
| 1161 | |
| 1162 | if (!pnbytes) |
| 1163 | return (l_uint8 *)ERROR_PTR("pnbytes not defined", procName, NULL); |
| 1164 | *pnbytes = 0; |
| 1165 | if (!filename) |
| 1166 | return (l_uint8 *)ERROR_PTR("filename not defined", procName, NULL); |
| 1167 | |
| 1168 | if ((fp = fopenReadStream(filename)) == NULL) |
| 1169 | return (l_uint8 *)ERROR_PTR("file stream not opened", procName, NULL); |
| 1170 | data = l_binaryReadStream(fp, pnbytes); |
| 1171 | fclose(fp); |
| 1172 | return data; |
| 1173 | } |
| 1174 | |
| 1175 | |
| 1176 | /*! |
no test coverage detected