1 /* 2 3 Boost Software License - Version 1.0 - August 17th, 2003 4 5 Permission is hereby granted, free of charge, to any person or organization 6 obtaining a copy of the software and accompanying documentation covered by 7 this license (the "Software") to use, reproduce, display, distribute, 8 execute, and transmit the Software, and to prepare derivative works of the 9 Software, and to permit third-parties to whom the Software is furnished to 10 do so, all subject to the following: 11 12 The copyright notices in the Software and this entire statement, including 13 the above license grant, this restriction and the following disclaimer, 14 must be included in all copies of the Software, in whole or in part, and 15 all derivative works of the Software, unless such copies or derivative 16 works are solely in the form of machine-executable object code generated by 17 a source language processor. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 DEALINGS IN THE SOFTWARE. 26 27 */ 28 module derelict.physfs.types; 29 30 // 2.0 Types 31 alias PHYSFS_uint8 = ubyte; 32 alias PHYSFS_sint8 = byte; 33 alias PHYSFS_uint16 = ushort; 34 alias PHYSFS_sint16 = short; 35 alias PHYSFS_uint32 = uint; 36 alias PHYSFS_sint32 = int; 37 alias PHYSFS_uint64 = ulong; 38 alias PHYSFS_sint64 = long; 39 40 struct PHYSFS_File { 41 void* opaque; 42 } 43 44 struct PHYSFS_ArchiveInfo { 45 const(char)* extension; 46 const(char)* description; 47 const(char)* author; 48 const(char)* url; 49 int supportSymlinks; 50 } 51 52 struct PHYSFS_Version { 53 PHYSFS_uint8 major; 54 PHYSFS_uint8 minor; 55 PHYSFS_uint8 patch; 56 } 57 58 enum ubyte PHYSFS_VERSION_MAJOR = 2; 59 enum ubyte PHYSFS_VERSION_MINOR = 1; 60 enum ubyte PHYSFS_VERSION_PATCH = 0; 61 62 void PHYSFS_VERSION(ref PHYSFS_Version* x) { 63 x.major = PHYSFS_VERSION_MAJOR; 64 x.minor = PHYSFS_VERSION_MINOR; 65 x.patch = PHYSFS_VERSION_PATCH; 66 } 67 68 struct PHYSFS_Allocator { 69 int function() Init; 70 void function() Deinit; 71 void* function(PHYSFS_uint64) Malloc; 72 void* function(void*, PHYSFS_uint64) Realloc; 73 void function(void*) Free; 74 } 75 76 extern(C) nothrow { 77 alias PHYSFS_StringCallback = void function(void*, const(char)*); 78 alias PHYSFS_EnumFilesCallback = void function(void*, const(char)*, const(char)*); 79 } 80 81 // 2.1 Types 82 alias PHYSFS_FileType = int; 83 enum { 84 PHYSFS_FILETYPE_REGULAR, 85 PHYSFS_FILETYPE_DIRECTORY, 86 PHYSFS_FILETYPE_SYMLINK, 87 PHYSFS_FILETYPE_OTHER 88 } 89 90 struct PHYSFS_Stat { 91 PHYSFS_sint64 filesize; 92 PHYSFS_sint64 modtime; 93 PHYSFS_sint64 createtime; 94 PHYSFS_sint64 accesstime; 95 PHYSFS_FileType filetype; 96 } 97 98 struct PHYSFS_Io { 99 PHYSFS_uint32 version_; 100 void* opaque; 101 extern(C) nothrow { 102 PHYSFS_sint64 function(PHYSFS_Io*, void*, PHYSFS_uint64) read; 103 PHYSFS_sint64 function(PHYSFS_Io*, const(void)*, PHYSFS_uint64) write; 104 PHYSFS_sint64 function(PHYSFS_Io*) tell; 105 PHYSFS_sint64 function(PHYSFS_Io*) length; 106 PHYSFS_Io* function(PHYSFS_Io*) duplicate; 107 int function(PHYSFS_Io*) flush; 108 void function(PHYSFS_Io*) destroy; 109 } 110 } 111 112 // This is not an explicit type in PHYSFS, just for convenience 113 // here to get the nothrow attribute only. 114 extern(C) nothrow alias UnmountCallback = void function(void*); 115 116 alias PHYSFS_ErrorCode = int; 117 enum { 118 PHYSFS_ERR_OK, 119 PHYSFS_ERR_OTHER_ERROR, 120 PHYSFS_ERR_OUT_OF_MEMORY, 121 PHYSFS_ERR_NOT_INITIALIZED, 122 PHYSFS_ERR_IS_INITIALIZED, 123 PHYSFS_ERR_ARGV0_IS_NULL, 124 PHYSFS_ERR_UNSUPPORTED, 125 PHYSFS_ERR_PAST_EOF, 126 PHYSFS_ERR_FILES_STILL_OPEN, 127 PHYSFS_ERR_INVALID_ARGUMENT, 128 PHYSFS_ERR_NOT_MOUNTED, 129 PHYSFS_ERR_NOT_FOUND, 130 PHYSFS_ERR_SYMLINK_FORBIDDEN, 131 PHYSFS_ERR_NO_WRITE_DIR, 132 PHYSFS_ERR_OPEN_FOR_READING, 133 PHYSFS_ERR_OPEN_FOR_WRITING, 134 PHYSFS_ERR_NOT_A_FILE, 135 PHYSFS_ERR_READ_ONLY, 136 PHYSFS_ERR_CORRUPT, 137 PHYSFS_ERR_SYMLINK_LOOP, 138 PHYSFS_ERR_IO, 139 PHYSFS_ERR_PERMISSION, 140 PHYSFS_ERR_NO_SPACE, 141 PHYSFS_ERR_BAD_FILENAME, 142 PHYSFS_ERR_BUSY, 143 PHYSFS_ERR_DIR_NOT_EMPTY, 144 PHYSFS_ERR_OS_ERROR, 145 PHYSFS_ERR_DUPLICATE 146 } 147 148 struct PHYSFS_Archiver { 149 PHYSFS_uint32 version_; 150 PHYSFS_ArchiveInfo info; 151 extern(C) nothrow { 152 void* function(PHYSFS_Io*, const(char)*, int) openArchive; 153 void function(void*, const(char)*, PHYSFS_EnumFilesCallback, const(char)*, void*) enumerateFiles; 154 PHYSFS_Io* function(void*, const(char)*) openRead; 155 PHYSFS_Io* function(void*, const(char)*) openWrite; 156 PHYSFS_Io* function(void*, const(char)*) openAppend; 157 int function(void*, const(char)*) remove; 158 int function(void*, const(char)*) mkdir; 159 int function(void*, const(char)*, PHYSFS_Stat*) stat; 160 void function(void*) closeArchive; 161 } 162 }