2
---------------------------------------------------------------------------
3
Open Asset Import Library (ASSIMP)
4
---------------------------------------------------------------------------
6
Copyright (c) 2006-2010, ASSIMP Development Team
10
Redistribution and use of this software in source and binary forms,
11
with or without modification, are permitted provided that the following
14
* Redistributions of source code must retain the above
15
copyright notice, this list of conditions and the
18
* Redistributions in binary form must reproduce the above
19
copyright notice, this list of conditions and the
20
following disclaimer in the documentation and/or other
21
materials provided with the distribution.
23
* Neither the name of the ASSIMP team, nor the names of its
24
contributors may be used to endorse or promote products
25
derived from this software without specific prior
26
written permission of the ASSIMP Development Team.
28
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
---------------------------------------------------------------------------
43
* @brief File system wrapper for C++. Inherit this class to supply
44
* custom file handling logic to the Import library.
47
#ifndef AI_IOSYSTEM_H_INC
48
#define AI_IOSYSTEM_H_INC
51
# error This header requires C++ to be used. aiFileIO.h is the \
52
corresponding C interface.
59
// ---------------------------------------------------------------------------
60
/** @brief CPP-API: Interface to the file system.
62
* Derive an own implementation from this interface to supply custom file handling
63
* to the importer library. If you implement this interface, you also want to
64
* supply a custom implementation for IOStream.
66
* @see Importer::SetIOHandler() */
67
class ASSIMP_API IOSystem : public Intern::AllocateFromAssimpHeap
71
// -------------------------------------------------------------------
72
/** @brief Default constructor.
74
* Create an instance of your derived class and assign it to an
75
* #Assimp::Importer instance by calling Importer::SetIOHandler().
79
// -------------------------------------------------------------------
80
/** @brief Virtual destructor.
82
* It is safe to be called from within DLL Assimp, we're constructed
90
// -------------------------------------------------------------------
91
/** @brief For backward compatibility
92
* @see Exists(const char*)
94
AI_FORCE_INLINE bool Exists( const std::string& pFile) const;
96
// -------------------------------------------------------------------
97
/** @brief Tests for the existence of a file at the given path.
99
* @param pFile Path to the file
100
* @return true if there is a file with this path, else false.
103
virtual bool Exists( const char* pFile) const = 0;
107
// -------------------------------------------------------------------
108
/** @brief Returns the system specific directory separator
109
* @return System specific directory separator
111
virtual char getOsSeparator() const = 0;
114
// -------------------------------------------------------------------
115
/** @brief Open a new file with a given path.
117
* When the access to the file is finished, call Close() to release
118
* all associated resources (or the virtual dtor of the IOStream).
120
* @param pFile Path to the file
121
* @param pMode Desired file I/O mode. Required are: "wb", "w", "wt",
124
* @return New IOStream interface allowing the lib to access
125
* the underlying file.
126
* @note When implementing this class to provide custom IO handling,
127
* you probably have to supply an own implementation of IOStream as well.
129
virtual IOStream* Open(const char* pFile,
130
const char* pMode = "rb") = 0;
132
// -------------------------------------------------------------------
133
/** @brief For backward compatibility
134
* @see Open(const char*, const char*)
136
inline IOStream* Open(const std::string& pFile,
137
const std::string& pMode = std::string("rb"));
141
// -------------------------------------------------------------------
142
/** @brief Closes the given file and releases all resources
143
* associated with it.
144
* @param pFile The file instance previously created by Open().
146
virtual void Close( IOStream* pFile) = 0;
148
// -------------------------------------------------------------------
149
/** @brief Compares two paths and check whether the point to
152
* The dummy implementation of this virtual performs a
153
* case-insensitive comparison of the given strings. The default IO
154
* system implementation uses OS mechanisms to convert relative into
155
* absolute paths, so the result can be trusted.
156
* @param one First file
157
* @param second Second file
158
* @return true if the paths point to the same file. The file needn't
159
* be existing, however.
161
virtual bool ComparePaths (const char* one,
162
const char* second) const;
164
// -------------------------------------------------------------------
165
/** @brief For backward compatibility
166
* @see ComparePaths(const char*, const char*)
168
inline bool ComparePaths (const std::string& one,
169
const std::string& second) const;
172
// ----------------------------------------------------------------------------
173
AI_FORCE_INLINE IOSystem::IOSystem()
178
// ----------------------------------------------------------------------------
179
AI_FORCE_INLINE IOSystem::~IOSystem()
184
// ----------------------------------------------------------------------------
185
// For compatibility, the interface of some functions taking a std::string was
186
// changed to const char* to avoid crashes between binary incompatible STL
187
// versions. This code her is inlined, so it shouldn't cause any problems.
188
// ----------------------------------------------------------------------------
190
// ----------------------------------------------------------------------------
191
AI_FORCE_INLINE IOStream* IOSystem::Open(const std::string& pFile,
192
const std::string& pMode)
195
// For compatibility, interface was changed to const char* to
196
// avoid crashes between binary incompatible STL versions
197
return Open(pFile.c_str(),pMode.c_str());
200
// ----------------------------------------------------------------------------
201
AI_FORCE_INLINE bool IOSystem::Exists( const std::string& pFile) const
204
// For compatibility, interface was changed to const char* to
205
// avoid crashes between binary incompatible STL versions
206
return Exists(pFile.c_str());
209
// ----------------------------------------------------------------------------
210
inline bool IOSystem::ComparePaths (const std::string& one,
211
const std::string& second) const
214
// For compatibility, interface was changed to const char* to
215
// avoid crashes between binary incompatible STL versions
216
return ComparePaths(one.c_str(),second.c_str());
219
// ----------------------------------------------------------------------------
222
#endif //AI_IOSYSTEM_H_INC