summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/assimp/include/assimp/IOSystem.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/assimp/include/assimp/IOSystem.hpp')
-rw-r--r--src/3rdparty/assimp/include/assimp/IOSystem.hpp109
1 files changed, 89 insertions, 20 deletions
diff --git a/src/3rdparty/assimp/include/assimp/IOSystem.hpp b/src/3rdparty/assimp/include/assimp/IOSystem.hpp
index abd7e5837..f4fbb6023 100644
--- a/src/3rdparty/assimp/include/assimp/IOSystem.hpp
+++ b/src/3rdparty/assimp/include/assimp/IOSystem.hpp
@@ -3,7 +3,8 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2016, assimp team
+Copyright (c) 2006-2017, assimp team
+
All rights reserved.
@@ -44,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* custom file handling logic to the Import library.
*/
+#pragma once
#ifndef AI_IOSYSTEM_H_INC
#define AI_IOSYSTEM_H_INC
@@ -54,10 +56,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "types.h"
+#ifdef _WIN32
+# include <direct.h>
+# include <stdlib.h>
+# include <stdio.h>
+#else
+# include <sys/stat.h>
+# include <sys/types.h>
+# include <unistd.h>
+#endif // _WIN32
+
#include <vector>
namespace Assimp {
-class IOStream;
+
+ class IOStream;
// ---------------------------------------------------------------------------
/** @brief CPP-API: Interface to the file system.
@@ -66,7 +79,8 @@ class IOStream;
* to the importer library. If you implement this interface, you also want to
* supply a custom implementation for IOStream.
*
- * @see Importer::SetIOHandler() */
+ * @see Importer::SetIOHandler()
+ */
class ASSIMP_API IOSystem
#ifndef SWIG
: public Intern::AllocateFromAssimpHeap
@@ -195,20 +209,37 @@ public:
*/
virtual bool PopDirectory();
+ // -------------------------------------------------------------------
+ /** @brief CReates an new directory at the given path.
+ * @param path [in] The path to create.
+ * @return True, when a directory was created. False if the directory
+ * cannot be created.
+ */
+ virtual bool CreateDirectory( const std::string &path );
+
+ // -------------------------------------------------------------------
+ /** @brief Will change the current directory to the given path.
+ * @param path [in] The path to change to.
+ * @return True, when the directory has changed successfully.
+ */
+ virtual bool ChangeDirectory( const std::string &path );
+
+ virtual bool DeleteFile( const std::string &file );
+
private:
std::vector<std::string> m_pathStack;
};
// ----------------------------------------------------------------------------
-AI_FORCE_INLINE IOSystem::IOSystem() :
- m_pathStack()
-{
+AI_FORCE_INLINE
+IOSystem::IOSystem()
+: m_pathStack() {
// empty
}
// ----------------------------------------------------------------------------
-AI_FORCE_INLINE IOSystem::~IOSystem()
-{
+AI_FORCE_INLINE
+IOSystem::~IOSystem() {
// empty
}
@@ -219,9 +250,8 @@ AI_FORCE_INLINE IOSystem::~IOSystem()
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
-AI_FORCE_INLINE IOStream* IOSystem::Open(const std::string& pFile,
- const std::string& pMode)
-{
+AI_FORCE_INLINE
+IOStream* IOSystem::Open(const std::string& pFile, const std::string& pMode) {
// NOTE:
// For compatibility, interface was changed to const char* to
// avoid crashes between binary incompatible STL versions
@@ -229,8 +259,8 @@ AI_FORCE_INLINE IOStream* IOSystem::Open(const std::string& pFile,
}
// ----------------------------------------------------------------------------
-AI_FORCE_INLINE bool IOSystem::Exists( const std::string& pFile) const
-{
+AI_FORCE_INLINE
+bool IOSystem::Exists( const std::string& pFile) const {
// NOTE:
// For compatibility, interface was changed to const char* to
// avoid crashes between binary incompatible STL versions
@@ -238,9 +268,8 @@ AI_FORCE_INLINE bool IOSystem::Exists( const std::string& pFile) const
}
// ----------------------------------------------------------------------------
-inline bool IOSystem::ComparePaths (const std::string& one,
- const std::string& second) const
-{
+AI_FORCE_INLINE
+bool IOSystem::ComparePaths (const std::string& one, const std::string& second) const {
// NOTE:
// For compatibility, interface was changed to const char* to
// avoid crashes between binary incompatible STL versions
@@ -248,7 +277,8 @@ inline bool IOSystem::ComparePaths (const std::string& one,
}
// ----------------------------------------------------------------------------
-inline bool IOSystem::PushDirectory( const std::string &path ) {
+AI_FORCE_INLINE
+bool IOSystem::PushDirectory( const std::string &path ) {
if ( path.empty() ) {
return false;
}
@@ -259,7 +289,8 @@ inline bool IOSystem::PushDirectory( const std::string &path ) {
}
// ----------------------------------------------------------------------------
-inline const std::string &IOSystem::CurrentDirectory() const {
+AI_FORCE_INLINE
+const std::string &IOSystem::CurrentDirectory() const {
if ( m_pathStack.empty() ) {
static const std::string Dummy("");
return Dummy;
@@ -268,12 +299,14 @@ inline const std::string &IOSystem::CurrentDirectory() const {
}
// ----------------------------------------------------------------------------
-inline size_t IOSystem::StackSize() const {
+AI_FORCE_INLINE
+size_t IOSystem::StackSize() const {
return m_pathStack.size();
}
// ----------------------------------------------------------------------------
-inline bool IOSystem::PopDirectory() {
+AI_FORCE_INLINE
+bool IOSystem::PopDirectory() {
if ( m_pathStack.empty() ) {
return false;
}
@@ -284,7 +317,43 @@ inline bool IOSystem::PopDirectory() {
}
// ----------------------------------------------------------------------------
+AI_FORCE_INLINE
+bool IOSystem::CreateDirectory( const std::string &path ) {
+ if ( path.empty() ) {
+ return false;
+ }
+
+#ifdef _WIN32
+ return 0 != ::_mkdir( path.c_str() );
+#else
+ return 0 != ::mkdir( path.c_str(), 0777 );
+#endif // _WIN32
+}
+
+// ----------------------------------------------------------------------------
+AI_FORCE_INLINE
+bool IOSystem::ChangeDirectory( const std::string &path ) {
+ if ( path.empty() ) {
+ return false;
+ }
+
+#ifdef _WIN32
+ return 0 != ::_chdir( path.c_str() );
+#else
+ return 0 != ::chdir( path.c_str() );
+#endif // _WIN32
+}
+
+// ----------------------------------------------------------------------------
+AI_FORCE_INLINE
+bool IOSystem::DeleteFile( const std::string &file ) {
+ if ( file.empty() ) {
+ return false;
+ }
+ const int retCode( ::remove( file.c_str() ) );
+ return ( 0 == retCode );
+}
} //!ns Assimp
#endif //AI_IOSYSTEM_H_INC