2008-05-09 17:24:28 +00:00
|
|
|
/*
|
2012-02-03 03:38:30 +00:00
|
|
|
Open Asset Import Library (assimp)
|
2008-05-09 17:24:28 +00:00
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
2012-02-03 03:38:30 +00:00
|
|
|
Copyright (c) 2006-2012, assimp team
|
2008-05-09 17:24:28 +00:00
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the
|
|
|
|
following conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer in the documentation and/or other
|
|
|
|
materials provided with the distribution.
|
|
|
|
|
2012-02-03 03:38:30 +00:00
|
|
|
* Neither the name of the assimp team, nor the names of its
|
2008-05-09 17:24:28 +00:00
|
|
|
contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior
|
2012-02-03 03:38:30 +00:00
|
|
|
written permission of the assimp team.
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
/** @file Default file I/O using fXXX()-family of functions */
|
|
|
|
#ifndef AI_DEFAULTIOSTREAM_H_INC
|
|
|
|
#define AI_DEFAULTIOSTREAM_H_INC
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2012-02-03 17:04:06 +00:00
|
|
|
#include "../include/assimp/IOStream.hpp"
|
2015-04-15 19:22:26 +00:00
|
|
|
#include "../include/assimp/importerdesc.h"
|
2015-04-16 00:55:41 +00:00
|
|
|
#include "Defines.h"
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2009-01-12 22:06:54 +00:00
|
|
|
namespace Assimp {
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2009-01-12 22:06:54 +00:00
|
|
|
// ----------------------------------------------------------------------------------
|
|
|
|
//! @class DefaultIOStream
|
|
|
|
//! @brief Default IO implementation, use standard IO operations
|
2009-02-13 22:03:57 +00:00
|
|
|
//! @note An instance of this class can exist without a valid file handle
|
|
|
|
//! attached to it. All calls fail, but the instance can nevertheless be
|
|
|
|
//! used with no restrictions.
|
2008-05-05 12:36:31 +00:00
|
|
|
class DefaultIOStream : public IOStream
|
|
|
|
{
|
|
|
|
friend class DefaultIOSystem;
|
2014-11-29 11:12:32 +00:00
|
|
|
#if __ANDROID__
|
|
|
|
#if __ANDROID_API__ > 9
|
|
|
|
#if defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
|
|
|
|
friend class AndroidJNIIOSystem;
|
|
|
|
#endif // defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
|
|
|
|
#endif // __ANDROID_API__ > 9
|
|
|
|
#endif // __ANDROID__
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
protected:
|
2014-11-29 11:12:32 +00:00
|
|
|
DefaultIOStream();
|
|
|
|
DefaultIOStream(FILE* pFile, const std::string &strFilename);
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** Destructor public to allow simple deletion to close the file. */
|
|
|
|
~DefaultIOStream ();
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
2014-11-29 11:12:32 +00:00
|
|
|
/// Read from stream
|
2008-05-05 12:36:31 +00:00
|
|
|
size_t Read(void* pvBuffer,
|
|
|
|
size_t pSize,
|
|
|
|
size_t pCount);
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
2014-11-29 11:12:32 +00:00
|
|
|
/// Write to stream
|
2008-05-05 12:36:31 +00:00
|
|
|
size_t Write(const void* pvBuffer,
|
|
|
|
size_t pSize,
|
|
|
|
size_t pCount);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
2014-11-29 11:12:32 +00:00
|
|
|
/// Seek specific position
|
2008-05-05 12:36:31 +00:00
|
|
|
aiReturn Seek(size_t pOffset,
|
|
|
|
aiOrigin pOrigin);
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
2014-11-29 11:12:32 +00:00
|
|
|
/// Get current seek position
|
2008-05-05 12:36:31 +00:00
|
|
|
size_t Tell() const;
|
|
|
|
|
2009-01-12 22:06:54 +00:00
|
|
|
// -------------------------------------------------------------------
|
2014-11-29 11:12:32 +00:00
|
|
|
/// Get size of file
|
2008-05-05 12:36:31 +00:00
|
|
|
size_t FileSize() const;
|
|
|
|
|
2009-01-12 22:06:54 +00:00
|
|
|
// -------------------------------------------------------------------
|
2014-11-29 11:12:32 +00:00
|
|
|
/// Flush file contents
|
2009-01-12 22:06:54 +00:00
|
|
|
void Flush();
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
private:
|
2014-11-29 11:12:32 +00:00
|
|
|
// File datastructure, using clib
|
2008-05-05 12:36:31 +00:00
|
|
|
FILE* mFile;
|
2014-11-29 11:12:32 +00:00
|
|
|
// Filename
|
2008-05-05 12:36:31 +00:00
|
|
|
std::string mFilename;
|
2009-02-13 22:03:57 +00:00
|
|
|
|
2014-11-29 11:12:32 +00:00
|
|
|
// Cached file size
|
2009-02-13 22:03:57 +00:00
|
|
|
mutable size_t cachedSize;
|
2008-05-05 12:36:31 +00:00
|
|
|
};
|
2009-01-12 22:06:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------------
|
2008-05-05 12:36:31 +00:00
|
|
|
inline DefaultIOStream::DefaultIOStream () :
|
2009-02-13 22:03:57 +00:00
|
|
|
mFile (NULL),
|
|
|
|
mFilename (""),
|
2011-04-22 21:29:18 +00:00
|
|
|
cachedSize (SIZE_MAX)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
// empty
|
|
|
|
}
|
|
|
|
|
2009-01-12 22:06:54 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------------
|
2008-05-05 12:36:31 +00:00
|
|
|
inline DefaultIOStream::DefaultIOStream (FILE* pFile,
|
|
|
|
const std::string &strFilename) :
|
|
|
|
mFile(pFile),
|
2009-02-13 22:03:57 +00:00
|
|
|
mFilename(strFilename),
|
2011-04-22 21:29:18 +00:00
|
|
|
cachedSize (SIZE_MAX)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
// empty
|
|
|
|
}
|
2009-01-12 22:06:54 +00:00
|
|
|
// ----------------------------------------------------------------------------------
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
} // ns assimp
|
|
|
|
|
|
|
|
#endif //!!AI_DEFAULTIOSTREAM_H_INC
|
2008-09-12 20:25:11 +00:00
|
|
|
|