1 module allegro5.fshook; 2 3 import allegro5.base; 4 import allegro5.file; 5 import allegro5.path; 6 import allegro5.internal.da5; 7 8 version(Windows) 9 { 10 private alias long off_t; 11 } 12 else 13 { 14 version(Tango) 15 { 16 import tango.stdc.posix.sys.types : off_t; 17 } 18 else 19 { 20 version(D_Version2) 21 { 22 import core.sys.posix.sys.types : off_t; 23 } 24 else 25 { 26 version(linux) 27 { 28 import std.c.linux.linux : off_t; 29 } 30 else 31 { 32 import std.c.freebsd.freebsd : off_t; 33 } 34 } 35 } 36 } 37 38 version (Tango) 39 { 40 import tango.stdc.time : time_t; 41 } 42 else 43 { 44 import core.stdc.time : time_t; 45 } 46 47 extern (C) 48 { 49 struct ALLEGRO_FS_ENTRY 50 { 51 const ALLEGRO_FS_INTERFACE* vtable; 52 } 53 54 enum ALLEGRO_FILE_MODE 55 { 56 ALLEGRO_FILEMODE_READ = 1, 57 ALLEGRO_FILEMODE_WRITE = 1 << 1, 58 ALLEGRO_FILEMODE_EXECUTE = 1 << 2, 59 ALLEGRO_FILEMODE_HIDDEN = 1 << 3, 60 ALLEGRO_FILEMODE_ISFILE = 1 << 4, 61 ALLEGRO_FILEMODE_ISDIR = 1 << 5, 62 } 63 64 struct ALLEGRO_FS_INTERFACE 65 { 66 ALLEGRO_FS_ENTRY* function(in char* path) fs_create_entry; 67 void function(ALLEGRO_FS_ENTRY* e) fs_destroy_entry; 68 const_char* function(ALLEGRO_FS_ENTRY* e) fs_entry_name; 69 bool function(ALLEGRO_FS_ENTRY* e) fs_update_entry; 70 uint function(ALLEGRO_FS_ENTRY* e) fs_entry_mode; 71 time_t function(ALLEGRO_FS_ENTRY* e) fs_entry_atime; 72 time_t function(ALLEGRO_FS_ENTRY* e) fs_entry_mtime; 73 time_t function(ALLEGRO_FS_ENTRY* e) fs_entry_ctime; 74 off_t function(ALLEGRO_FS_ENTRY* e) fs_entry_size; 75 bool function(ALLEGRO_FS_ENTRY* e) fs_entry_exists; 76 bool function(ALLEGRO_FS_ENTRY* e) fs_remove_entry; 77 78 bool function(ALLEGRO_FS_ENTRY* e) fs_open_directory; 79 ALLEGRO_FS_ENTRY* function(ALLEGRO_FS_ENTRY* e) fs_read_directory; 80 bool function(ALLEGRO_FS_ENTRY* e) fs_close_directory; 81 82 bool function(in char* path) fs_filename_exists; 83 bool function(in char* path) fs_remove_filename; 84 ALLEGRO_PATH* function() fs_get_current_directory; 85 bool function(in char* path) fs_change_directory; 86 bool function(in char* path) fs_make_directory; 87 88 ALLEGRO_FILE * function(ALLEGRO_FS_ENTRY* e, in char* mode) fs_open_file; 89 } 90 91 ALLEGRO_FS_ENTRY* al_create_fs_entry(in char* path); 92 void al_destroy_fs_entry(ALLEGRO_FS_ENTRY* e); 93 const_char* al_get_fs_entry_name(ALLEGRO_FS_ENTRY* e); 94 bool al_update_fs_entry(ALLEGRO_FS_ENTRY* e); 95 uint al_get_fs_entry_mode(ALLEGRO_FS_ENTRY* e); 96 time_t al_get_fs_entry_atime(ALLEGRO_FS_ENTRY* e); 97 time_t al_get_fs_entry_mtime(ALLEGRO_FS_ENTRY* e); 98 time_t al_get_fs_entry_ctime(ALLEGRO_FS_ENTRY* e); 99 off_t al_get_fs_entry_size(ALLEGRO_FS_ENTRY* e); 100 bool al_fs_entry_exists(ALLEGRO_FS_ENTRY* e); 101 bool al_remove_fs_entry(ALLEGRO_FS_ENTRY* e); 102 103 bool al_open_directory(ALLEGRO_FS_ENTRY* e); 104 ALLEGRO_FS_ENTRY* al_read_directory(ALLEGRO_FS_ENTRY* e); 105 bool al_close_directory(ALLEGRO_FS_ENTRY* e); 106 107 bool al_filename_exists(in char* path); 108 bool al_remove_filename(in char* path); 109 char* al_get_current_directory(); 110 bool al_change_directory(in char* path); 111 bool al_make_directory(in char* path); 112 113 ALLEGRO_FILE* al_open_fs_entry(ALLEGRO_FS_ENTRY* e, in char* mode); 114 115 enum ALLEGRO_FOR_EACH_FS_ENTRY_RESULT 116 { 117 ALLEGRO_FOR_EACH_FS_ENTRY_ERROR = -1, 118 ALLEGRO_FOR_EACH_FS_ENTRY_OK = 0, 119 ALLEGRO_FOR_EACH_FS_ENTRY_SKIP = 1, 120 ALLEGRO_FOR_EACH_FS_ENTRY_STOP = 2 121 } 122 123 int al_for_each_fs_entry(ALLEGRO_FS_ENTRY *dir, 124 int function(ALLEGRO_FS_ENTRY*, void*) callback, 125 void *extra); 126 127 /* Thread-local state. */ 128 ALLEGRO_FS_INTERFACE* al_get_fs_interface(); 129 void al_set_fs_interface(in ALLEGRO_FS_INTERFACE* vtable); 130 void al_set_standard_fs_interface(); 131 }