filerw.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. struct rtgui_filerw
  21. {
  22. int (*seek) (struct rtgui_filerw *context, rt_off_t offset, int whence);
  23. int (*read) (struct rtgui_filerw *context, void *buffer, rt_size_t size, rt_size_t count);
  24. int (*write)(struct rtgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count);
  25. int (*tell) (struct rtgui_filerw *context);
  26. int (*eof) (struct rtgui_filerw *context);
  27. int (*close)(struct rtgui_filerw *context);
  28. };
  29. typedef struct rtgui_filerw rtgui_filerw_t;
  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* mem, 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