aiFileIO.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. typedef aiFileIO (*aiFileOpenProc)(C_STRUCT aiFileIO*, const char*, const char*);
  44. typedef aiReturn (*aiFileCloseProc)(C_STRUCT aiFileIO*);
  45. typedef unsigned long (*aiFileReadWriteProc)(C_STRUCT aiFileIO*, char*, unsigned int, unsigned int);
  46. typedef unsigned long (*aiFileTellProc)(C_STRUCT aiFileIO*);
  47. // ---------------------------------------------------------------------------
  48. /** Define seek origins in fseek()-style.
  49. */
  50. // ---------------------------------------------------------------------------
  51. enum aiOrigin
  52. {
  53. aiOrigin_SET = 0x0, //!< Set position
  54. aiOrigin_CUR = 0x1, //!< Current position
  55. aiOrigin_END = 0x2 //!< End of file
  56. };
  57. typedef aiReturn (*aiFileSeek)(aiFileIO*, unsigned long, aiOrigin);
  58. typedef char* aiUserData;
  59. // ---------------------------------------------------------------------------
  60. /** Data structure to wrap a set of fXXXX (e.g fopen) replacement functions
  61. *
  62. * The functions behave the same way as their appropriate fXXXX
  63. * counterparts in the CRT.
  64. */
  65. // ---------------------------------------------------------------------------
  66. struct aiFileIO
  67. {
  68. //! User data assigned to the structure
  69. aiUserData UserData;
  70. //! Function used to open a new file
  71. aiFileOpenProc OpenFunc;
  72. //! Function used to close an existing file
  73. aiFileCloseProc CloseFunc;
  74. //! Function used to read from a file
  75. aiFileReadWriteProc ReadFunc;
  76. //! Function used to write to a file
  77. aiFileReadWriteProc WriteFunc;
  78. //! Function used to retrieve the current
  79. //! position of the file cursor (ftell())
  80. aiFileTellProc TellProc;
  81. //! Function used to set the current position
  82. //! of the file cursor (fseek())
  83. aiFileSeek SeekProc;
  84. };
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif // AI_FILEIO_H_INC