common.bmx 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. ' Copyright (c) 2020-2023 Bruce A Henderson
  2. '
  3. ' This software is provided 'as-is', without any express or implied
  4. ' warranty. In no event will the authors be held liable for any damages
  5. ' arising from the use of this software.
  6. '
  7. ' Permission is granted to anyone to use this software for any purpose,
  8. ' including commercial applications, and to alter it and redistribute it
  9. ' freely, subject to the following restrictions:
  10. '
  11. ' 1. The origin of this software must not be misrepresented; you must not
  12. ' claim that you wrote the original software. If you use this software
  13. ' in a product, an acknowledgment in the product documentation would be
  14. ' appreciated but is not required.
  15. ' 2. Altered source versions must be plainly marked as such, and must not be
  16. ' misrepresented as being the original software.
  17. ' 3. This notice may not be removed or altered from any source distribution.
  18. '
  19. SuperStrict
  20. Import Pub.Physfs
  21. Import Pub.Stdc
  22. Import "../../pub.mod/physfs.mod/physfs/src/*.h"
  23. Import "glue.c"
  24. Extern
  25. Function bmx_PHYSFS_init:Int()
  26. Function PHYSFS_deinit:Int()
  27. Function PHYSFS_isInit:Int()
  28. Function bmx_PHYSFS_getErrorForCode:String(errorCode:EMaxIOErrorCode)
  29. Function bmx_PHYSFS_getLastError:String()
  30. Function bmx_PHYSFS_getLastErrorCode:EMaxIOErrorCode()
  31. Function bmx_PHYSFS_mount:Int(newDir:String, mountPoint:String, appendToPath:Int)
  32. Function bmx_PHYSFS_getBaseDir:String()
  33. Function bmx_PHYSFS_getPrefDir:String(org:String, app:String)
  34. Function bmx_PHYSFS_mountMemory:Int(dirPtr:Byte Ptr, dirLen:Int, newDir:String, mountPoint:String, appendToPath:Int)
  35. Function bmx_PHYSFS_setWriteDir:Int(newDir:String)
  36. Function bmx_PHYSFS_getWriteDir:String()
  37. Function bmx_PHYSFS_getRealDir:String(filename:String)
  38. Function bmx_PHYSFS_getMountPoint:String(dir:String)
  39. Function bmx_PHYSFS_setRoot:Int(archive:String, subdir:String)
  40. Function bmx_PHYSFS_unmount:Int(oldDir:String)
  41. Function bmx_PHYSFS_getSearchPath:String[]()
  42. Function PHYSFS_permitSymbolicLinks:Int(allow:Int)
  43. Function PHYSFS_symbolicLinksPermitted:Int()
  44. Function PHYSFS_tell:Long(filePtr:Byte Ptr)
  45. Function PHYSFS_seek:Int(filePtr:Byte Ptr, newPos:Long)
  46. Function PHYSFS_fileLength:Long(filePtr:Byte Ptr)
  47. Function PHYSFS_readBytes:Long(filePtr:Byte Ptr, buf:Byte Ptr, length:ULong)
  48. Function PHYSFS_writeBytes:Long(filePtr:Byte Ptr, buf:Byte Ptr, length:ULong)
  49. Function PHYSFS_flush:Int(filePtr:Byte Ptr)
  50. Function PHYSFS_close:Int(filePtr:Byte Ptr)
  51. Function PHYSFS_setBuffer:Int(filePtr:Byte Ptr, bufsize:ULong)
  52. Function bmx_PHYSFS_openAppend:Byte Ptr(path:String)
  53. Function bmx_PHYSFS_openWrite:Byte Ptr(path:String)
  54. Function bmx_PHYSFS_openRead:Byte Ptr(path:String)
  55. Function bmx_PHYSFS_stat:Int(filename:String, stat:SMaxIO_Stat Var)
  56. Function bmx_PHYSFS_delete:Int(path:String)
  57. Function bmx_PHYSFS_mkdir:Int(dirName:String)
  58. Function bmx_blitzio_readdir:Byte Ptr(dir:String)
  59. Function bmx_blitzio_nextFile:String(dir:Byte Ptr)
  60. Function bmx_blitzio_closeDir(dir:Byte Ptr)
  61. End Extern
  62. Rem
  63. bbdoc: File statistics, including file size, modification time, etc.
  64. End rem
  65. Struct SMaxIO_Stat
  66. Rem
  67. bbdoc: The size of the file, in bytes.
  68. End Rem
  69. Field _filesize:Long
  70. Rem
  71. bbdoc: The modification time of the file, in seconds since the epoch.
  72. End Rem
  73. Field _modtime:Long
  74. Rem
  75. bbdoc: The creation time of the file, in seconds since the epoch.
  76. End Rem
  77. Field _createtime:Long
  78. Rem
  79. bbdoc: The last access time of the file, in seconds since the epoch.
  80. End Rem
  81. Field _accesstime:Long
  82. Rem
  83. bbdoc: The type of the file.
  84. End Rem
  85. Field _filetype:EMaxIOFileType
  86. Rem
  87. bbdoc: Whether the file is read only or not.
  88. End Rem
  89. Field _readonly:Int
  90. Rem
  91. bbdoc: Returns the file modified time as an #SDateTime.
  92. End Rem
  93. Method ModeTimeAsDateTime:SDateTime()
  94. Return SDateTime.FromEpoch(_modTime)
  95. End Method
  96. Rem
  97. bbdoc: Returns the file creation time as an #SDateTime.
  98. End Rem
  99. Method CreatTimeAsDateTime:SDateTime()
  100. Return SDateTime.FromEpoch(_createTime)
  101. End Method
  102. Rem
  103. bbdoc: Returns the last access time as an #SDateTime.
  104. End Rem
  105. Method AccessTimeAsDateTime:SDateTime()
  106. Return SDateTime.FromEpoch(_accessTime)
  107. End Method
  108. End Struct
  109. Rem
  110. bbdoc: The type of file.
  111. End Rem
  112. Enum EMaxIOFileType:Int
  113. REGULAR
  114. DIRECTORY
  115. SYMLINK
  116. OTHER
  117. End Enum
  118. Enum EMaxIOErrorCode:Int
  119. OK
  120. OTHER_ERROR
  121. OUT_OF_MEMORY
  122. NOT_INITIALIZED
  123. IS_INITIALIZED
  124. ARGV0_IS_NULL
  125. UNSUPPORTED
  126. PAST_EOF
  127. FILES_STILL_OPEN
  128. INVALID_ARGUMENT
  129. NOT_MOUNTED
  130. NOT_FOUND
  131. SYMLINK_FORBIDDEN
  132. NO_WRITE_DIR
  133. OPEN_FOR_READING
  134. OPEN_FOR_WRITING
  135. NOT_A_FILE
  136. READ_ONLY
  137. CORRUPT
  138. SYMLINK_LOOP
  139. IO
  140. PERMISSION
  141. NO_SPACE
  142. BAD_FILENAME
  143. BUSY
  144. DIR_NOT_EMPTY
  145. OS_ERROR
  146. DUPLICATE
  147. BAD_PASSWORD
  148. APP_CALLBACK
  149. End Enum