Don't like ads? PRO users don't see any ads ;-)
Guest

allegrofile.h

By: Ultraboy94 on Jan 28th, 2013  |  syntax: None  |  size: 3.69 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #ifndef __al_included_allegro5_file_h
  2. #define __al_included_allegro5_file_h
  3.  
  4. #include "allegro5/base.h"
  5. #include "allegro5/path.h"
  6. #include "allegro5/utf8.h"
  7.  
  8. #ifdef __cplusplus
  9.    extern "C" {
  10. #endif
  11.  
  12.  
  13. /* Type: ALLEGRO_FILE
  14.  */
  15. typedef struct ALLEGRO_FILE ALLEGRO_FILE;
  16.  
  17.  
  18. /* Type: ALLEGRO_FILE_INTERFACE
  19.  */
  20. typedef struct ALLEGRO_FILE_INTERFACE
  21. {
  22.    AL_METHOD(void *,  fi_fopen, (const char *path, const char *mode));
  23.    AL_METHOD(void,    fi_fclose, (ALLEGRO_FILE *handle));
  24.    AL_METHOD(size_t,  fi_fread, (ALLEGRO_FILE *f, void *ptr, size_t size));
  25.    AL_METHOD(size_t,  fi_fwrite, (ALLEGRO_FILE *f, const void *ptr, size_t size));
  26.    AL_METHOD(bool,    fi_fflush, (ALLEGRO_FILE *f));
  27.    AL_METHOD(int64_t, fi_ftell, (ALLEGRO_FILE *f));
  28.    AL_METHOD(bool,    fi_fseek, (ALLEGRO_FILE *f, int64_t offset, int whence));
  29.    AL_METHOD(bool,    fi_feof, (ALLEGRO_FILE *f));
  30.    AL_METHOD(bool,    fi_ferror, (ALLEGRO_FILE *f));
  31.    AL_METHOD(void,    fi_fclearerr, (ALLEGRO_FILE *f));
  32.    AL_METHOD(int,     fi_fungetc, (ALLEGRO_FILE *f, int c));
  33.    AL_METHOD(off_t,   fi_fsize, (ALLEGRO_FILE *f));
  34. } ALLEGRO_FILE_INTERFACE;
  35.  
  36.  
  37. /* Enum: ALLEGRO_SEEK
  38.  */
  39. typedef enum ALLEGRO_SEEK
  40. {
  41.    ALLEGRO_SEEK_SET = 0,
  42.    ALLEGRO_SEEK_CUR,
  43.    ALLEGRO_SEEK_END
  44. } ALLEGRO_SEEK;
  45.  
  46.  
  47. /* The basic operations. */
  48. AL_FUNC(ALLEGRO_FILE*, al_fopen, (const char *path, const char *mode));
  49. AL_FUNC(ALLEGRO_FILE*, al_fopen_interface, (const ALLEGRO_FILE_INTERFACE *vt, const char *path, const char *mode));
  50. AL_FUNC(ALLEGRO_FILE*, al_create_file_handle, (const ALLEGRO_FILE_INTERFACE *vt, void *userdata));
  51. AL_FUNC(void, al_fclose, (ALLEGRO_FILE *f));
  52. AL_FUNC(size_t, al_fread, (ALLEGRO_FILE *f, void *ptr, size_t size));
  53. AL_FUNC(size_t, al_fwrite, (ALLEGRO_FILE *f, const void *ptr, size_t size));
  54. AL_FUNC(bool, al_fflush, (ALLEGRO_FILE *f));
  55. AL_FUNC(int64_t, al_ftell, (ALLEGRO_FILE *f));
  56. AL_FUNC(bool, al_fseek, (ALLEGRO_FILE *f, int64_t offset, int whence));
  57. AL_FUNC(bool, al_feof, (ALLEGRO_FILE *f));
  58. AL_FUNC(bool, al_ferror, (ALLEGRO_FILE *f));
  59. AL_FUNC(void, al_fclearerr, (ALLEGRO_FILE *f));
  60. AL_FUNC(int, al_fungetc, (ALLEGRO_FILE *f, int c));
  61. AL_FUNC(int64_t, al_fsize, (ALLEGRO_FILE *f));
  62.  
  63. /* Convenience functions. */
  64. AL_FUNC(int, al_fgetc, (ALLEGRO_FILE *f));
  65. AL_FUNC(int, al_fputc, (ALLEGRO_FILE *f, int c));
  66. AL_FUNC(int16_t, al_fread16le, (ALLEGRO_FILE *f));
  67. AL_FUNC(int16_t, al_fread16be, (ALLEGRO_FILE *f));
  68. AL_FUNC(size_t, al_fwrite16le, (ALLEGRO_FILE *f, int16_t w));
  69. AL_FUNC(size_t, al_fwrite16be, (ALLEGRO_FILE *f, int16_t w));
  70. AL_FUNC(int32_t, al_fread32le, (ALLEGRO_FILE *f));
  71. AL_FUNC(int32_t, al_fread32be, (ALLEGRO_FILE *f));
  72. AL_FUNC(size_t, al_fwrite32le, (ALLEGRO_FILE *f, int32_t l));
  73. AL_FUNC(size_t, al_fwrite32be, (ALLEGRO_FILE *f, int32_t l));
  74. AL_FUNC(char*, al_fgets, (ALLEGRO_FILE *f, char * const p, size_t max));
  75. AL_FUNC(ALLEGRO_USTR *, al_fget_ustr, (ALLEGRO_FILE *f));
  76. AL_FUNC(int, al_fputs, (ALLEGRO_FILE *f, const char *p));
  77.  
  78. /* Specific to stdio backend. */
  79. AL_FUNC(ALLEGRO_FILE*, al_fopen_fd, (int fd, const char *mode));
  80. AL_FUNC(ALLEGRO_FILE*, al_make_temp_file, (const char *tmpl,
  81.       ALLEGRO_PATH **ret_path));
  82.  
  83. /* Specific to slices. */
  84. AL_FUNC(ALLEGRO_FILE*, al_fopen_slice, (ALLEGRO_FILE *fp,
  85.       size_t initial_size, const char *mode));
  86.  
  87. /* Thread-local state. */
  88. AL_FUNC(const ALLEGRO_FILE_INTERFACE *, al_get_new_file_interface, (void));
  89. AL_FUNC(void, al_set_new_file_interface, (const ALLEGRO_FILE_INTERFACE *
  90.       file_interface));
  91. AL_FUNC(void, al_set_standard_file_interface, (void));
  92.  
  93. /* ALLEGRO_FILE field accessors */
  94. AL_FUNC(void *, al_get_file_userdata, (ALLEGRO_FILE *f));
  95.  
  96.  
  97. #ifdef __cplusplus
  98.    }
  99. #endif
  100.  
  101. #endif
  102.  
  103. /* vim: set sts=3 sw=3 et: */