1 module allegro5.file; 2 3 import allegro5.internal.da5; 4 import allegro5.path; 5 import allegro5.utf8; 6 7 import core.stdc.stdarg : va_list; 8 9 version(Windows) 10 { 11 private alias long off_t; 12 } 13 else 14 { 15 import core.sys.posix.sys.types : off_t; 16 } 17 18 nothrow @nogc extern (C) 19 { 20 struct ALLEGRO_FILE_INTERFACE 21 { 22 void* function(in char* path, in char* mode) fi_fopen; 23 bool function(ALLEGRO_FILE* handle) fi_fclose; 24 size_t function(ALLEGRO_FILE* f, void* ptr, size_t size) fi_fread; 25 size_t function(ALLEGRO_FILE* f, in void* ptr, size_t size) fi_fwrite; 26 bool function(ALLEGRO_FILE* f) fi_fflush; 27 long function(ALLEGRO_FILE* f) fi_ftell; 28 bool function(ALLEGRO_FILE* f, long offset, int whence) fi_fseek; 29 bool function(ALLEGRO_FILE* f) fi_feof; 30 int function(ALLEGRO_FILE* f) fi_ferror; 31 const(char)* function(ALLEGRO_FILE* f) fi_ferrmsg(ALLEGRO_FILE *f); 32 void function(ALLEGRO_FILE* f) fi_fclearerr; 33 int function(ALLEGRO_FILE* f, int c) fi_fungetc; 34 off_t function(ALLEGRO_FILE* f) fi_fsize; 35 } 36 37 struct ALLEGRO_FILE 38 { 39 } 40 41 enum ALLEGRO_SEEK 42 { 43 ALLEGRO_SEEK_SET = 0, 44 ALLEGRO_SEEK_CUR, 45 ALLEGRO_SEEK_END 46 } 47 48 49 /* The basic operations. */ 50 ALLEGRO_FILE* al_fopen(in char* path, in char* mode); 51 ALLEGRO_FILE* al_fopen_interface(in ALLEGRO_FILE_INTERFACE* vt, in char* path, in char* mode); 52 ALLEGRO_FILE* al_create_file_handle(in ALLEGRO_FILE_INTERFACE* vt, void* userdata); 53 bool al_fclose(ALLEGRO_FILE* f); 54 size_t al_fread(ALLEGRO_FILE* f, void* ptr, size_t size); 55 size_t al_fwrite(ALLEGRO_FILE* f, in void* ptr, size_t size); 56 bool al_fflush(ALLEGRO_FILE* f); 57 long al_ftell(ALLEGRO_FILE* f); 58 bool al_fseek(ALLEGRO_FILE* f, long offset, int whence); 59 bool al_feof(ALLEGRO_FILE* f); 60 int al_ferror(ALLEGRO_FILE* f); 61 const(char)* al_ferrmsg(ALLEGRO_FILE *f); 62 void al_fclearerr(ALLEGRO_FILE *f); 63 int al_fungetc(ALLEGRO_FILE* f, int c); 64 long al_fsize(ALLEGRO_FILE* f); 65 66 /* Convenience functions. */ 67 int al_fgetc(ALLEGRO_FILE* f); 68 int al_fputc(ALLEGRO_FILE* f, int c); 69 short al_fread16le(ALLEGRO_FILE* f); 70 short al_fread16be(ALLEGRO_FILE* f); 71 size_t al_fwrite16le(ALLEGRO_FILE* f, short w); 72 size_t al_fwrite16be(ALLEGRO_FILE* f, short w); 73 int al_fread32le(ALLEGRO_FILE* f); 74 int al_fread32be(ALLEGRO_FILE* f); 75 size_t al_fwrite32le(ALLEGRO_FILE* f, int l); 76 size_t al_fwrite32be(ALLEGRO_FILE* f, int l); 77 char* al_fgets(ALLEGRO_FILE* f, in char* p, size_t max); 78 ALLEGRO_USTR* al_fget_ustr(ALLEGRO_FILE* f); 79 int al_fputs(ALLEGRO_FILE* f, in char* p); 80 int al_fprintf(ALLEGRO_FILE *f, const char *format, ...); 81 int al_vfprintf(ALLEGRO_FILE *f, const char* format, va_list args); 82 83 /* Specific to stdio backend. */ 84 ALLEGRO_FILE* al_fopen_fd(int fd, in char* mode); 85 ALLEGRO_FILE* al_make_temp_file(in char* tmpl, ALLEGRO_PATH **ret_path); 86 87 /* Specific to slices. */ 88 ALLEGRO_FILE* al_fopen_slice(ALLEGRO_FILE* fp, size_t initial_size, in char *mode); 89 90 /* Thread-local state. */ 91 ALLEGRO_FILE_INTERFACE* al_get_new_file_interface(); 92 void al_set_new_file_interface(in ALLEGRO_FILE_INTERFACE* file_interface); 93 void al_set_standard_file_interface(); 94 void* al_get_file_userdata(ALLEGRO_FILE *f); 95 }