FileIO.h 934 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef __FILE_IO_H__
  2. #define __FILE_IO_H__
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. // Function : read all data from file to a buffer.
  6. // Note : The buffer is malloc in this function and need to be free outside by user !
  7. // Parameter :
  8. // size_t *p_len : getting the data length, i.e. the file length.
  9. // const char *filename : file name
  10. // Return :
  11. // non-NULL pointer : success. Return the data buffer pointer. The data length will be on *p_len
  12. // NULL : failed
  13. uint8_t *loadFromFile (size_t *p_len, const char *filename);
  14. // Function : write data from buffer to a file.
  15. // Parameter :
  16. // const uint8_t *p_buf : data buffer pointer
  17. // size_t len : data length
  18. // const char *filename : file name
  19. // Return :
  20. // 0 : failed
  21. // 1 : success
  22. int saveToFile (const uint8_t *p_buf, size_t len, const char *filename);
  23. #endif // __FILE_IO_H__