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