filerw.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * File : filerw.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-10-16 Bernard first version
  13. */
  14. #ifndef __RTGUI_FILERW_H__
  15. #define __RTGUI_FILERW_H__
  16. #include <rtgui/rtgui.h>
  17. #define RTGUI_FILE_SEEK_SET 0
  18. #define RTGUI_FILE_SEEK_CUR 1
  19. #define RTGUI_FILE_SEEK_END 2
  20. typedef struct rtgui_filerw rtgui_filerw_t;
  21. struct rtgui_filerw
  22. {
  23. int (*seek) (struct rtgui_filerw *context, rt_off_t offset, int whence);
  24. int (*read) (struct rtgui_filerw *context, void *buffer, rt_size_t size, rt_size_t count);
  25. int (*write)(struct rtgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count);
  26. int (*tell) (struct rtgui_filerw *context);
  27. int (*eof) (struct rtgui_filerw *context);
  28. int (*close)(struct rtgui_filerw *context);
  29. };
  30. struct rtgui_filerw* rtgui_filerw_create_file(const char *filename, const char *mode);
  31. struct rtgui_filerw* rtgui_filerw_create_mem(const rt_uint8_t *data, rt_size_t size);
  32. int rtgui_filerw_seek (struct rtgui_filerw *context, rt_off_t offset, int whence);
  33. int rtgui_filerw_read (struct rtgui_filerw *context, void *buffer, rt_size_t size, rt_size_t count);
  34. int rtgui_filerw_write(struct rtgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count);
  35. int rtgui_filerw_tell (struct rtgui_filerw *context);
  36. int rtgui_filerw_eof (struct rtgui_filerw *context);
  37. int rtgui_filerw_close(struct rtgui_filerw *context);
  38. /* get memory data from filerw memory object */
  39. const rt_uint8_t* rtgui_filerw_mem_getdata(struct rtgui_filerw* context);
  40. #endif