#ifndef __cfileio_bi__
#define __cfileio_bi__

' Defines generic C routines to access memory-mapped files

#include once "ctypes.bi"

extern "C"

type aiFileIO_ as aiFileIO
type aiFile_   as aiFile

' aiFile callbacks
type aiFileWriteProc as function (byval pf as aiFile_ ptr,byval pBuffer as const any ptr,byval elementSize as size_t,byval nElemets as size_t) as size_t
type aiFileReadProc  as function (byval pf as aiFile_ ptr,byval pBuffer as       any ptr,byval elementSize as size_t,byval nElemets as size_t) as size_t
type aiFileTellProc  as function (byval pf as aiFile_ ptr) as size_t
type aiFileFlushProc as sub      (byval pf as aiFile_ ptr)
type aiFileSeek      as function (byval pf as aiFile_ ptr,byval offset as size_t,byval origin as aiOrigin) as aiReturn

' aiFileIO callbacks
type aiFileOpenProc  as function (byval pf as aiFileIO_ ptr,byval fileName as const zstring ptr, byval openMode as const zstring ptr) as aiFile_ ptr
type aiFileCloseProc as sub      (byval pf as aiFileIO_ ptr,byval pf as aiFile_ ptr)

' Represents user-defined data
type aiUserData as any ptr

' C-API: File system callbacks
' Provided are functions to open and close files.
' Supply a custom structure to the import function. 
' If you don't, a default implementation is used.
' Use custom  file systems to enable reading from other sources, such as ZIPs or memory locations.
type aiFileIO
  ' Function used to open a new file
  as aiFileOpenProc OpenProc
  ' Function used to close an existing file
  as aiFileCloseProc CloseProc
  ' User-defined, opaque data
  as aiUserData UserData
end type


' C-API: File callbacks
'  Actually, it's a data structure to wrap a set of fXXXX (e.g fopen) replacement functions.
' The default implementation of the functions utilizes the fXXX functions from the CRT. 
' However, you can supply a custom implementation to Assimp by delivering a custom aiFileIO. 
' Use this to enable reading from other sources, such as ZIP archives or memory locations.
type aiFile
  ' Callback to read from a file
  as aiFileReadProc ReadProc
  ' Callback to write to a file
  as aiFileWriteProc WriteProc
  ' Callback to retrieve the current position of the file cursor (ftell())
  as aiFileTellProc TellProc
  ' Callback to retrieve the size of the file, in bytes
  as aiFileTellProc FileSizeProc
  ' Callback to set the current position of the file cursor (fseek())
  as aiFileSeek SeekProc
  ' Callback to flush the file contents
  as aiFileFlushProc FlushProc
  ' User-defined, opaque data
  as aiUserData UserData
end type

end extern
#endif ' __cfileio_bi__

