file_stream.h 994 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #include <stdlib.h>
  3. #include <storage/storage.h>
  4. #include "stream.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. /**
  9. * Allocate file stream
  10. * @return Stream*
  11. */
  12. Stream* file_stream_alloc(Storage* storage);
  13. /**
  14. * Opens an existing file or create a new one.
  15. * @param stream pointer to file stream object.
  16. * @param path path to file
  17. * @param access_mode access mode from FS_AccessMode
  18. * @param open_mode open mode from FS_OpenMode
  19. * @return success flag. You need to close the file even if the open operation failed.
  20. */
  21. bool file_stream_open(
  22. Stream* stream,
  23. const char* path,
  24. FS_AccessMode access_mode,
  25. FS_OpenMode open_mode);
  26. /**
  27. * Closes the file.
  28. * @param stream
  29. * @return true
  30. * @return false
  31. */
  32. bool file_stream_close(Stream* stream);
  33. /**
  34. * Retrieves the error id from the file object
  35. * @param stream pointer to stream object.
  36. * @return FS_Error error id
  37. */
  38. FS_Error file_stream_get_error(Stream* stream);
  39. #ifdef __cplusplus
  40. }
  41. #endif