aiFileIO.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (ASSIMP)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2008, ASSIMP Development Team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the ASSIMP team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the ASSIMP Development Team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. /** @file Defines generic routines to access memory-mapped files
  35. */
  36. #ifndef AI_FILEIO_H_INC
  37. #define AI_FILEIO_H_INC
  38. #include "aiTypes.h"
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. struct aiFileIO;
  43. struct aiFile;
  44. typedef aiFile* (*aiFileOpenProc)(C_STRUCT aiFileIO*, const char*, const char*);
  45. typedef void (*aiFileCloseProc)(C_STRUCT aiFileIO*, C_STRUCT aiFile*);
  46. typedef size_t (*aiFileWriteProc)(C_STRUCT aiFile*, const char*, size_t, size_t);
  47. typedef size_t (*aiFileReadProc)(C_STRUCT aiFile*, char*, size_t,size_t);
  48. typedef size_t (*aiFileTellProc)(C_STRUCT aiFile*);
  49. // ---------------------------------------------------------------------------
  50. /** Define seek origins in fseek()-style.
  51. */
  52. // ---------------------------------------------------------------------------
  53. enum aiOrigin
  54. {
  55. aiOrigin_SET = 0x0, //!< Set position
  56. aiOrigin_CUR = 0x1, //!< Current position
  57. aiOrigin_END = 0x2 //!< End of file
  58. };
  59. typedef aiReturn (*aiFileSeek)(aiFile*, size_t, aiOrigin);
  60. typedef char* aiUserData;
  61. // ---------------------------------------------------------------------------
  62. /** Defines how C-Assimp accesses files. Provided are functions to open
  63. * and close files.
  64. */
  65. // ---------------------------------------------------------------------------
  66. struct aiFileIO
  67. {
  68. //! Function used to open a new file
  69. aiFileOpenProc OpenProc;
  70. //! Function used to close an existing file
  71. aiFileCloseProc CloseProc;
  72. //! User-defined data
  73. aiUserData UserData;
  74. };
  75. // ---------------------------------------------------------------------------
  76. /** Data structure to wrap a set of fXXXX (e.g fopen) replacement functions
  77. *
  78. * The functions behave the same way as their appropriate fXXXX
  79. * counterparts in the CRT.
  80. */
  81. // ---------------------------------------------------------------------------
  82. struct aiFile
  83. {
  84. //! Function used to read from a file
  85. aiFileReadProc ReadProc;
  86. //! Function used to write to a file
  87. aiFileWriteProc WriteProc;
  88. //! Function used to retrieve the current
  89. //! position of the file cursor (ftell())
  90. aiFileTellProc TellProc;
  91. //! Function used to retrieve the size of the file, in bytes
  92. aiFileTellProc FileSizeProc;
  93. //! Function used to set the current position
  94. //! of the file cursor (fseek())
  95. aiFileSeek SeekProc;
  96. //! User-defined data
  97. aiUserData UserData;
  98. };
  99. #ifdef __cplusplus
  100. }
  101. #endif
  102. #endif // AI_FILEIO_H_INC