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 import core.sys.posix.sys.types : off_t; 15 } 16 17 import core.stdc.time : time_t; 18 19 nothrow @nogc extern (C) 20 { 21 struct ALLEGRO_FS_ENTRY 22 { 23 const ALLEGRO_FS_INTERFACE* vtable; 24 } 25 26 enum ALLEGRO_FILE_MODE 27 { 28 ALLEGRO_FILEMODE_READ = 1, 29 ALLEGRO_FILEMODE_WRITE = 1 << 1, 30 ALLEGRO_FILEMODE_EXECUTE = 1 << 2, 31 ALLEGRO_FILEMODE_HIDDEN = 1 << 3, 32 ALLEGRO_FILEMODE_ISFILE = 1 << 4, 33 ALLEGRO_FILEMODE_ISDIR = 1 << 5, 34 } 35 36 struct ALLEGRO_FS_INTERFACE 37 { 38 ALLEGRO_FS_ENTRY* function(in char* path) fs_create_entry; 39 void function(ALLEGRO_FS_ENTRY* e) fs_destroy_entry; 40 const(char)* function(ALLEGRO_FS_ENTRY* e) fs_entry_name; 41 bool function(ALLEGRO_FS_ENTRY* e) fs_update_entry; 42 uint function(ALLEGRO_FS_ENTRY* e) fs_entry_mode; 43 time_t function(ALLEGRO_FS_ENTRY* e) fs_entry_atime; 44 time_t function(ALLEGRO_FS_ENTRY* e) fs_entry_mtime; 45 time_t function(ALLEGRO_FS_ENTRY* e) fs_entry_ctime; 46 off_t function(ALLEGRO_FS_ENTRY* e) fs_entry_size; 47 bool function(ALLEGRO_FS_ENTRY* e) fs_entry_exists; 48 bool function(ALLEGRO_FS_ENTRY* e) fs_remove_entry; 49 50 bool function(ALLEGRO_FS_ENTRY* e) fs_open_directory; 51 ALLEGRO_FS_ENTRY* function(ALLEGRO_FS_ENTRY* e) fs_read_directory; 52 bool function(ALLEGRO_FS_ENTRY* e) fs_close_directory; 53 54 bool function(in char* path) fs_filename_exists; 55 bool function(in char* path) fs_remove_filename; 56 ALLEGRO_PATH* function() fs_get_current_directory; 57 bool function(in char* path) fs_change_directory; 58 bool function(in char* path) fs_make_directory; 59 60 ALLEGRO_FILE * function(ALLEGRO_FS_ENTRY* e, in char* mode) fs_open_file; 61 } 62 63 ALLEGRO_FS_ENTRY* al_create_fs_entry(in char* path); 64 void al_destroy_fs_entry(ALLEGRO_FS_ENTRY* e); 65 const(char)* al_get_fs_entry_name(ALLEGRO_FS_ENTRY* e); 66 bool al_update_fs_entry(ALLEGRO_FS_ENTRY* e); 67 uint al_get_fs_entry_mode(ALLEGRO_FS_ENTRY* e); 68 time_t al_get_fs_entry_atime(ALLEGRO_FS_ENTRY* e); 69 time_t al_get_fs_entry_mtime(ALLEGRO_FS_ENTRY* e); 70 time_t al_get_fs_entry_ctime(ALLEGRO_FS_ENTRY* e); 71 off_t al_get_fs_entry_size(ALLEGRO_FS_ENTRY* e); 72 bool al_fs_entry_exists(ALLEGRO_FS_ENTRY* e); 73 bool al_remove_fs_entry(ALLEGRO_FS_ENTRY* e); 74 75 bool al_open_directory(ALLEGRO_FS_ENTRY* e); 76 ALLEGRO_FS_ENTRY* al_read_directory(ALLEGRO_FS_ENTRY* e); 77 bool al_close_directory(ALLEGRO_FS_ENTRY* e); 78 79 bool al_filename_exists(in char* path); 80 bool al_remove_filename(in char* path); 81 char* al_get_current_directory(); 82 bool al_change_directory(in char* path); 83 bool al_make_directory(in char* path); 84 85 ALLEGRO_FILE* al_open_fs_entry(ALLEGRO_FS_ENTRY* e, in char* mode); 86 87 enum ALLEGRO_FOR_EACH_FS_ENTRY_RESULT 88 { 89 ALLEGRO_FOR_EACH_FS_ENTRY_ERROR = -1, 90 ALLEGRO_FOR_EACH_FS_ENTRY_OK = 0, 91 ALLEGRO_FOR_EACH_FS_ENTRY_SKIP = 1, 92 ALLEGRO_FOR_EACH_FS_ENTRY_STOP = 2 93 } 94 95 int al_for_each_fs_entry(ALLEGRO_FS_ENTRY *dir, 96 int function(ALLEGRO_FS_ENTRY*, void*) callback, 97 void *extra); 98 99 /* Thread-local state. */ 100 ALLEGRO_FS_INTERFACE* al_get_fs_interface(); 101 void al_set_fs_interface(in ALLEGRO_FS_INTERFACE* vtable); 102 void al_set_standard_fs_interface(); 103 }