Assimp v5.2.2 (January 2022)
The Asset-Importer-Lib API documentation.
Assimp::IOSystem Class Referenceabstract

CPP-API: Interface to the file system. More...

#include <IOSystem.hpp>

Inherits Intern::AllocateFromAssimpHeap.

Inherited by Assimp::BlobIOSystem, Assimp::DefaultIOSystem, Assimp::MemoryIOSystem, and Assimp::ZipArchiveIOSystem.

Public Member Functions

virtual bool ChangeDirectory (const std::string &path)
 Will change the current directory to the given path. More...
 
virtual void Close (IOStream *pFile)=0
 Closes the given file and releases all resources associated with it. More...
 
virtual bool ComparePaths (const char *one, const char *second) const
 Compares two paths and check whether the point to identical files. More...
 
bool ComparePaths (const std::string &one, const std::string &second) const
 For backward compatibility. More...
 
virtual bool CreateDirectory (const std::string &path)
 CReates an new directory at the given path. More...
 
virtual const std::string & CurrentDirectory () const
 Returns the top directory from the stack. More...
 
virtual bool DeleteFile (const std::string &file)
 Will delete the given file. More...
 
virtual bool Exists (const char *pFile) const =0
 Tests for the existence of a file at the given path. More...
 
AI_FORCE_INLINE bool Exists (const std::string &pFile) const
 For backward compatibility. More...
 
virtual char getOsSeparator () const =0
 Returns the system specific directory separator. More...
 
 IOSystem () AI_NO_EXCEPT
 Default constructor. More...
 
virtual IOStreamOpen (const char *pFile, const char *pMode="rb")=0
 Open a new file with a given path. More...
 
IOStreamOpen (const std::string &pFile, const std::string &pMode=std::string("rb"))
 For backward compatibility. More...
 
virtual bool PopDirectory ()
 Pops the top directory from the stack. More...
 
virtual bool PushDirectory (const std::string &path)
 Pushes a new directory onto the directory stack. More...
 
virtual size_t StackSize () const
 Returns the number of directories stored on the stack. More...
 
virtual ~IOSystem ()
 Virtual destructor. More...
 

Detailed Description

CPP-API: Interface to the file system.

Derive an own implementation from this interface to supply custom file handling to the importer library. If you implement this interface, you also want to supply a custom implementation for IOStream.

See also
Importer::SetIOHandler()

Constructor & Destructor Documentation

◆ IOSystem()

AI_FORCE_INLINE Assimp::IOSystem::IOSystem ( )

Default constructor.

Create an instance of your derived class and assign it to an Assimp::Importer instance by calling Importer::SetIOHandler().

◆ ~IOSystem()

AI_FORCE_INLINE Assimp::IOSystem::~IOSystem ( )
virtualdefault

Virtual destructor.

It is safe to be called from within DLL Assimp, we're constructed on Assimp's heap.

Member Function Documentation

◆ ChangeDirectory()

AI_FORCE_INLINE bool Assimp::IOSystem::ChangeDirectory ( const std::string &  path)
virtual

Will change the current directory to the given path.

Parameters
path[in] The path to change to.
Returns
True, when the directory has changed successfully.

Reimplemented in Assimp::MemoryIOSystem.

◆ Close()

virtual void Assimp::IOSystem::Close ( IOStream pFile)
pure virtual

Closes the given file and releases all resources associated with it.

Parameters
pFileThe file instance previously created by Open().

Implemented in Assimp::BlobIOSystem, Assimp::DefaultIOSystem, Assimp::MemoryIOSystem, and Assimp::ZipArchiveIOSystem.

◆ ComparePaths() [1/2]

virtual bool Assimp::IOSystem::ComparePaths ( const char *  one,
const char *  second 
) const
virtual

Compares two paths and check whether the point to identical files.

The dummy implementation of this virtual member performs a case-insensitive comparison of the given strings. The default IO system implementation uses OS mechanisms to convert relative into absolute paths, so the result can be trusted.

Parameters
oneFirst file
secondSecond file
Returns
true if the paths point to the same file. The file needn't be existing, however.

Reimplemented in Assimp::DefaultIOSystem, and Assimp::MemoryIOSystem.

◆ ComparePaths() [2/2]

AI_FORCE_INLINE bool Assimp::IOSystem::ComparePaths ( const std::string &  one,
const std::string &  second 
) const
inline

For backward compatibility.

See also
ComparePaths(const char*, const char*)

◆ CreateDirectory()

AI_FORCE_INLINE bool Assimp::IOSystem::CreateDirectory ( const std::string &  path)
virtual

CReates an new directory at the given path.

Parameters
path[in] The path to create.
Returns
True, when a directory was created. False if the directory cannot be created.

Reimplemented in Assimp::MemoryIOSystem.

◆ CurrentDirectory()

virtual const std::string & Assimp::IOSystem::CurrentDirectory ( ) const
virtual

Returns the top directory from the stack.

Returns
The directory on the top of the stack. Returns empty when no directory was pushed to the stack.

Reimplemented in Assimp::MemoryIOSystem.

◆ DeleteFile()

AI_FORCE_INLINE bool Assimp::IOSystem::DeleteFile ( const std::string &  file)
virtual

Will delete the given file.

Parameters
file[in] The filename
Returns
true, if the file wase deleted, false if not.

Reimplemented in Assimp::MemoryIOSystem.

◆ Exists() [1/2]

virtual bool Assimp::IOSystem::Exists ( const char *  pFile) const
pure virtual

Tests for the existence of a file at the given path.

Parameters
pFilePath to the file
Returns
true if there is a file with this path, else false.

Implemented in Assimp::BlobIOSystem, Assimp::DefaultIOSystem, Assimp::MemoryIOSystem, and Assimp::ZipArchiveIOSystem.

◆ Exists() [2/2]

AI_FORCE_INLINE bool Assimp::IOSystem::Exists ( const std::string &  pFile) const

For backward compatibility.

See also
Exists(const char*)

◆ getOsSeparator()

virtual char Assimp::IOSystem::getOsSeparator ( ) const
pure virtual

Returns the system specific directory separator.

Returns
System specific directory separator

Implemented in Assimp::BlobIOSystem, Assimp::DefaultIOSystem, Assimp::MemoryIOSystem, and Assimp::ZipArchiveIOSystem.

◆ Open() [1/2]

virtual IOStream * Assimp::IOSystem::Open ( const char *  pFile,
const char *  pMode = "rb" 
)
pure virtual

Open a new file with a given path.

When the access to the file is finished, call Close() to release all associated resources (or the virtual dtor of the IOStream).

Parameters
pFilePath to the file
pModeDesired file I/O mode. Required are: "wb", "w", "wt", "rb", "r", "rt".
Returns
New IOStream interface allowing the lib to access the underlying file.
Note
When implementing this class to provide custom IO handling, you probably have to supply an own implementation of IOStream as well.

Implemented in Assimp::BlobIOSystem, Assimp::DefaultIOSystem, Assimp::MemoryIOSystem, and Assimp::ZipArchiveIOSystem.

◆ Open() [2/2]

AI_FORCE_INLINE IOStream * Assimp::IOSystem::Open ( const std::string &  pFile,
const std::string &  pMode = std::string("rb") 
)
inline

For backward compatibility.

See also
Open(const char*, const char*)

◆ PopDirectory()

AI_FORCE_INLINE bool Assimp::IOSystem::PopDirectory ( )
virtual

Pops the top directory from the stack.

Returns
True, when a directory was on the stack. False if no directory was on the stack.

Reimplemented in Assimp::MemoryIOSystem.

◆ PushDirectory()

AI_FORCE_INLINE bool Assimp::IOSystem::PushDirectory ( const std::string &  path)
virtual

Pushes a new directory onto the directory stack.

Parameters
pathPath to push onto the stack.
Returns
True, when push was successful, false if path is empty.

Reimplemented in Assimp::MemoryIOSystem.

◆ StackSize()

AI_FORCE_INLINE size_t Assimp::IOSystem::StackSize ( ) const
virtual

Returns the number of directories stored on the stack.

Returns
The number of directories of the stack.

Reimplemented in Assimp::MemoryIOSystem.


The documentation for this class was generated from the following file: