FBX C++ API Reference
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FbxFile Class Reference

#include <fbxfile.h>

Class Description

Class for interfacing with files, providing a similar interface for files independant of the OS or filesystem.

Definition at line 27 of file fbxfile.h.

Public Types

enum  EMode {
  eNone, eReadOnly, eReadWrite, eCreateWriteOnly,
  eCreateReadWrite, eCreateAppend
}
 
enum  ESeekPos { eBegin, eCurrent, eEnd }
 

Public Member Functions

 FbxFile ()
 
virtual ~FbxFile ()
 
virtual bool Open (const char *pFileName_UTF8, const EMode pMode=eCreateReadWrite, const bool pBinary=true)
 Opens a file on disk using the specified read/write mode. More...
 
virtual bool Open (FbxStream *pStream, void *pStreamData, const char *pMode)
 Opens a file from a data stream using the specified read/write mode. More...
 
virtual bool Close ()
 Closes a file, freeing its handle. More...
 
virtual void Seek (const FbxInt64 pOffset, const ESeekPos pSeekPos=eBegin)
 Seek to a specific position in the file, starting from either beginning, current position or end. More...
 
virtual FbxInt64 Tell () const
 Returns the position at which the file cursor currently is. More...
 
virtual size_t Read (void *pDstBuf, const size_t pSize)
 Read a part of the file into a buffer. More...
 
virtual char * ReadString (char *pDstBuf, const size_t pDstSize, bool pStopAtFirstWhiteSpace=false)
 Read a part of the file as a string into a buffer. More...
 
virtual size_t Write (const void *pSrcBuf, const size_t pSize)
 Write a buffer to an opened file. More...
 
virtual bool WriteFormat (const char *pFormat,...)
 Write a formatted string to an opened file. More...
 
virtual bool Truncate (const FbxInt64 pSize)
 Modify the size of a file. More...
 
virtual bool EndOfFile () const
 Checks whether the current file cursor position is at the end of file. More...
 
virtual FbxInt64 GetSize ()
 Gets the size of the currently opened file. More...
 
virtual void GetMemoryFileInfo (void **pMemPtr, size_t pSize)
 Unused function in this default implementation. More...
 
bool IsOpen () const
 Checks whether the file is currently opened. More...
 
bool IsStream () const
 Checks whether the file is currently opened with a user-provided streaming interface instead of just the file name. More...
 
const char * GetFilePathName () const
 Returns the full file path name, as provided when opening it. More...
 
EMode GetFileMode () const
 Returns the mode with which the file was opened, when calling the Open() method. More...
 
int GetLastError ()
 Returns last encountered error when performing any operation on the file. More...
 
void ClearError ()
 Resets the current error code and the end of file indicator of the opened file. More...
 

Protected Attributes

FILE * mFilePtr
 
FbxStreammStreamPtr
 
bool mIsOpen
 
bool mIsStream
 
EMode mMode
 
FbxString mFileName
 

Member Enumeration Documentation

◆ EMode

enum EMode
Enumerator
eNone 
eReadOnly 
eReadWrite 
eCreateWriteOnly 
eCreateReadWrite 
eCreateAppend 

Definition at line 30 of file fbxfile.h.

◆ ESeekPos

enum ESeekPos
Enumerator
eBegin 
eCurrent 
eEnd 

Definition at line 31 of file fbxfile.h.

Constructor & Destructor Documentation

◆ FbxFile()

FbxFile ( )

◆ ~FbxFile()

virtual ~FbxFile ( )
virtual

Member Function Documentation

◆ Open() [1/2]

virtual bool Open ( const char *  pFileName_UTF8,
const EMode  pMode = eCreateReadWrite,
const bool  pBinary = true 
)
virtual

Opens a file on disk using the specified read/write mode.

Parameters
pFileName_UTF8Filename in UTF8 (compatible with ASCII)
pModeMode in which to open the file, e.g. eReadOnly, eCreateReadWrite, etc.
pBinaryWhether the file is to be opened in binary or text mode.
Returns
True if opening is successful.

◆ Open() [2/2]

virtual bool Open ( FbxStream pStream,
void *  pStreamData,
const char *  pMode 
)
virtual

Opens a file from a data stream using the specified read/write mode.

Parameters
pStreamStream instance with which the file will be read/written
pStreamDataUser-defined data to pass as a parameter to the stream's Open() method.
pModeDeprecated/Unused.
Returns
True if opening is successful.

◆ Close()

virtual bool Close ( )
virtual

Closes a file, freeing its handle.

Returns
True if closing is successful.

◆ Seek()

virtual void Seek ( const FbxInt64  pOffset,
const ESeekPos  pSeekPos = eBegin 
)
virtual

Seek to a specific position in the file, starting from either beginning, current position or end.

Parameters
pOffsetOffset to seek to (advance the file position cursor) starting from pSeekPos
pSeekPosStarting position from which to seek to. Beginning, current position or end.

◆ Tell()

virtual FbxInt64 Tell ( ) const
virtual

Returns the position at which the file cursor currently is.

For example, will be ==0 for beginning and ==FileSize for end.

Returns
The position at which the file cursor currently is.

◆ Read()

virtual size_t Read ( void *  pDstBuf,
const size_t  pSize 
)
virtual

Read a part of the file into a buffer.

Parameters
pDstBufPre-allocated buffer in which to read data
pSizeSize of the data chunk to be read in bytes
Returns
Number of bytes read.

◆ ReadString()

virtual char* ReadString ( char *  pDstBuf,
const size_t  pDstSize,
bool  pStopAtFirstWhiteSpace = false 
)
virtual

Read a part of the file as a string into a buffer.

Parameters
pDstBufPre-allocated buffer in which to read the string
pDstSizeSize of the data chunk to be read in characters
pStopAtFirstWhiteSpaceIf true, will stop reading at first white space, otherwise it will stop at the first line feed (
)
Returns
Pointer on the data read. Equivalent to parameter pDstBuf

◆ Write()

virtual size_t Write ( const void *  pSrcBuf,
const size_t  pSize 
)
virtual

Write a buffer to an opened file.

Parameters
pSrcBufPre-allocated buffer from which to write data
pSizeSize of the data chunk to be written in bytes
Returns
Number of bytes written.

◆ WriteFormat()

virtual bool WriteFormat ( const char *  pFormat,
  ... 
)
virtual

Write a formatted string to an opened file.

Parameters
pFormatPre-allocated format buffer from which to write data
...Variable number of arguments describing the values in the previous parameter.
Returns
True if data was successfully written

◆ Truncate()

virtual bool Truncate ( const FbxInt64  pSize)
virtual

Modify the size of a file.

Null characters ('\0') are appended if the file is extended. If the file is truncated, all data from the end of the shortened file to the original length of the file is lost. Please note that this function considers the current file cursor as the beginning of the file. It is therefore required to use Seek(0) prior to calling it if we want the size specified by the pSize parameter to be absolute.

Parameters
pSizeNew desired file size
Returns
True if file was successfully truncated

◆ EndOfFile()

virtual bool EndOfFile ( ) const
virtual

Checks whether the current file cursor position is at the end of file.

Returns
True if the cursor is at the end of file, false otherwise.

◆ GetSize()

virtual FbxInt64 GetSize ( )
virtual

Gets the size of the currently opened file.

Returns
File size

◆ GetMemoryFileInfo()

virtual void GetMemoryFileInfo ( void **  pMemPtr,
size_t  pSize 
)
virtual

Unused function in this default implementation.

Must be implemented by memory files.

Parameters
pMemPtrUnused
pSizeUnused

◆ IsOpen()

bool IsOpen ( ) const

Checks whether the file is currently opened.

Returns
True if file is opened, false otherwise

◆ IsStream()

bool IsStream ( ) const

Checks whether the file is currently opened with a user-provided streaming interface instead of just the file name.

Returns
True if file has been opened with a stream interface, false otherwise

◆ GetFilePathName()

const char* GetFilePathName ( ) const

Returns the full file path name, as provided when opening it.

Returns
File full path

◆ GetFileMode()

EMode GetFileMode ( ) const

Returns the mode with which the file was opened, when calling the Open() method.

Returns
Mode with which the file was opened

◆ GetLastError()

int GetLastError ( )

Returns last encountered error when performing any operation on the file.

Returns
Last error code

◆ ClearError()

void ClearError ( )

Resets the current error code and the end of file indicator of the opened file.

Member Data Documentation

◆ mFilePtr

FILE* mFilePtr
protected

Definition at line 153 of file fbxfile.h.

◆ mStreamPtr

FbxStream* mStreamPtr
protected

Definition at line 154 of file fbxfile.h.

◆ mIsOpen

bool mIsOpen
protected

Definition at line 155 of file fbxfile.h.

◆ mIsStream

bool mIsStream
protected

Definition at line 156 of file fbxfile.h.

◆ mMode

EMode mMode
protected

Definition at line 157 of file fbxfile.h.

◆ mFileName

FbxString mFileName
protected

Definition at line 158 of file fbxfile.h.


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