Go to the documentation of this file.
50 #ifndef AI_IOSYSTEM_H_INC
51 #define AI_IOSYSTEM_H_INC
54 # pragma GCC system_header
58 # error This header requires C++ to be used. aiFileIO.h is the \
59 corresponding C interface.
69 # include <sys/stat.h>
70 # include <sys/types.h>
91 :
public Intern::AllocateFromAssimpHeap
116 AI_FORCE_INLINE
bool Exists(
const std::string& pFile)
const;
124 virtual bool Exists(
const char* pFile)
const = 0;
148 const char* pMode =
"rb") = 0;
154 inline IOStream* Open(
const std::string& pFile,
155 const std::string& pMode = std::string(
"rb"));
178 const char* second)
const;
184 inline bool ComparePaths (
const std::string& one,
185 const std::string& second)
const;
192 virtual bool PushDirectory(
const std::string &path );
199 virtual const std::string &CurrentDirectory()
const;
205 virtual size_t StackSize()
const;
212 virtual bool PopDirectory();
220 virtual bool CreateDirectory(
const std::string &path );
227 virtual bool ChangeDirectory(
const std::string &path );
229 virtual bool DeleteFile(
const std::string &file );
232 std::vector<std::string> m_pathStack;
260 return Open(pFile.c_str(),pMode.c_str());
269 return Exists(pFile.c_str());
284 if ( path.empty() ) {
288 m_pathStack.push_back( path );
296 if ( m_pathStack.empty() ) {
297 static const std::string Dummy(
"");
300 return m_pathStack[ m_pathStack.size()-1 ];
306 return m_pathStack.size();
312 if ( m_pathStack.empty() ) {
316 m_pathStack.pop_back();
324 if ( path.empty() ) {
329 return 0 != ::_mkdir( path.c_str() );
331 return 0 != ::mkdir( path.c_str(), 0777 );
338 if ( path.empty() ) {
343 return 0 != ::_chdir( path.c_str() );
345 return 0 != ::chdir( path.c_str() );
352 bool IOSystem::DeleteFile(
const std::string &file ) {
353 if ( file.empty() ) {
356 const int retCode( ::remove( file.c_str() ) );
357 return ( 0 == retCode );
361 #endif //AI_IOSYSTEM_H_INC
virtual bool ChangeDirectory(const std::string &path)
Will change the current directory to the given path.
Definition: IOSystem.hpp:337
virtual bool CreateDirectory(const std::string &path)
CReates an new directory at the given path.
Definition: IOSystem.hpp:323
IOSystem() AI_NO_EXCEPT
Default constructor.
Definition: IOSystem.hpp:237
virtual size_t StackSize() const
Returns the number of directories stored on the stack.
Definition: IOSystem.hpp:305
virtual bool ComparePaths(const char *one, const char *second) const
Compares two paths and check whether the point to identical files.
virtual ~IOSystem()
Virtual destructor.
Definition: IOSystem.hpp:244
virtual bool Exists(const char *pFile) const =0
Tests for the existence of a file at the given path.
virtual bool PushDirectory(const std::string &path)
Pushes a new directory onto the directory stack.
Definition: IOSystem.hpp:283
virtual char getOsSeparator() const =0
Returns the system specific directory separator.
virtual bool PopDirectory()
Pops the top directory from the stack.
Definition: IOSystem.hpp:311
CPP-API: Interface to the file system.
Definition: IOSystem.hpp:93
virtual const std::string & CurrentDirectory() const
Returns the top directory from the stack.
Definition: IOSystem.hpp:295
Definition: ai_assert.h:50
virtual void Close(IOStream *pFile)=0
Closes the given file and releases all resources associated with it.
virtual IOStream * Open(const char *pFile, const char *pMode="rb")=0
Open a new file with a given path.
AI_FORCE_INLINE bool Exists(const std::string &pFile) const
For backward compatibility.
Definition: IOSystem.hpp:265
CPP-API: Class to handle file I/O for C++.
Definition: IOStream.hpp:75