Generic utility class to manipulate files on different file systems similarly.
Used internally by different readers(KFbxReader) and writer (KFbxWriter) objects. SDK users can also use this class to manipulate files in the file system.
Definition at line 217 of file kfbxutilities.h.
#include <kfbxutilities.h>
Public Member Functions |
|
KFbxFile () | |
Default constructor. |
|
virtual | ~KFbxFile () |
Destructor. |
|
bool | Open (const char *pFileName, eFileMode pMode, bool pText) |
Open file. |
|
bool | Open (const char *pFileName, const char *pMode) |
Open file. |
|
bool | IsOpened () |
Return the status that if the file is
opened. |
|
bool | Close () |
Close the file. |
|
size_t | Read (void *pBuffer, size_t pSize) |
Reads a number of bytes into a block of
memory. |
|
char * | ReadString (char *pBuffer, int pMaxSize, bool pStopAtFirstWhiteSpace=false) |
Read a block of text into a buffer up to the
first new-line up to the specified maximum size. |
|
kInt32 | ReadInt32 (kInt32 *pBuffer, bool pSwab=false) |
Read 32-bit integer. |
|
kUInt32 | ReadUInt32 (kUInt32 *pBuffer, bool pSwab=false) |
Read unsigned 32-bit integer. |
|
kInt16 | ReadInt16 (kInt16 *pBuffer, bool pSwab=false) |
Read 16-bit integer. |
|
kUInt16 | ReadUInt16 (kUInt16 *pBuffer, bool pSwab=false) |
Read unsigned 16-bit integer. |
|
char | ReadChar (char *pBuffer) |
Read a char. |
|
kUChar | ReadUChar (kUChar *pBuffer) |
Read unsigned char. |
|
size_t | Write (const void *pBuffer, size_t pSize) |
Write file. |
|
void | Seek (eSeekPos pSeekPosition, long pOffset) |
Set the file cursor position. |
|
long | GetPosition () |
Get file cursor's position. |
|
void | SetPosition (long pPosition) |
Set file cursor's position. |
|
bool | EndOfFile () |
Returns true if the end of the file has been
reached. |
|
char * | GetFullFileName () |
Returns the file name and full path.
|
|
eFileMode | GetFileMode () |
Returns the mode used to open the file.
|
|
int | GetError () |
Get last error. |
|
void | ClearError () |
Clear error. |
|
void | Format (const char *pFormat,...) |
Outputs the files content to the standard
output stream using a printf-style formatting string. |
|
int | Truncate (size_t pSize) |
Truncates file to a specified size. |
|
Static Public Member Functions |
|
static int | Remove (const char *pFileName) |
Deletes the file. |
|
static int | Rename (const char *pFileName, const char *pNewName) |
Rename file. |
KFbxFile | ( | ) |
Default constructor.
virtual ~KFbxFile | ( | ) | [virtual] |
Destructor.
bool Open | ( | const char * | pFileName, |
eFileMode | pMode, | ||
bool | pText | ||
) |
Open file.
pFileName | const char* The file name. |
pMode | eFileMode The file open mode. KFBX_READ / KFBX_WRITE / KFBX_READWRITE / KFBX_APPEND |
pText | bool The file is text or binary. |
bool Open | ( | const char * | pFileName, |
const char * | pMode | ||
) |
Open file.
pFileName | const char * The file name. |
pMode | const char * The file open mode. |
bool IsOpened | ( | ) |
bool Close | ( | ) |
size_t Read | ( | void * | pBuffer, |
size_t | pSize | ||
) |
Reads a number of bytes into a block of memory.
pBuffer | Pointer to a block of memory. |
pSize | Bytes count to read. |
char* ReadString | ( | char * | pBuffer, |
int | pMaxSize, | ||
bool | pStopAtFirstWhiteSpace =
false |
||
) |
Read a block of text into a buffer up to the first new-line up to the specified maximum size.
pBuffer | Pointer to a block of memory. |
pMaxSize | size of the pBuffer allocated. |
pStopAtFirstWhiteSpace | If this parameter is true, the function will have the same behavior as fscanf: characters are read until pMaxSize or a space character is reached. |
Read 32-bit integer.
pBuffer | Pointer to a block of memory. |
pSwab | indicate if a bytes swap is required (big-endian/little-endian) |
Read unsigned 32-bit integer.
pBuffer | Pointer to a block of memory. |
pSwab | indicate if a bytes swap is required (big-endian/little-endian) |
Read 16-bit integer.
pBuffer | Pointer to a block of memory. |
pSwab | indicate if a bytes swap is required (big-endian/little-endian) |
Read unsigned 16-bit integer.
pBuffer | Pointer to a block of memory. |
pSwab | indicate if a bytes swap is required (big-endian/little-endian) |
char ReadChar | ( | char * | pBuffer | ) |
Read a char.
pBuffer | Pointer to a block of memory. |
Read unsigned char.
pBuffer | Pointer to a block of memory. |
size_t Write | ( | const void * | pBuffer, |
size_t | pSize | ||
) |
Write file.
pBuffer | Pointer to a block of memory to be written. |
pSize | number of bytes to be written. |
void Seek | ( | eSeekPos | pSeekPosition, |
long | pOffset | ||
) |
Set the file cursor position.
pSeekPosition | like KFBX_BEGIN/KFBX_CURRENT/KFBX_END |
pOffset | offset value from the seek position |
long GetPosition | ( | ) |
void SetPosition | ( | long | pPosition | ) |
bool EndOfFile | ( | ) |
Returns true if the end of the file has been reached.
true
if at the end, false
otherwise.char* GetFullFileName | ( | ) |
eFileMode GetFileMode | ( | ) |
Returns the mode used to open the file.
int GetError | ( | ) |
void ClearError | ( | ) |
Clear error.
void Format | ( | const char * | pFormat, |
... | |||
) |
Outputs the files content to the standard output stream using a printf-style formatting string.
pFormat | Pointer to a string memory buffer. |
... | variable parameters list |
int Truncate | ( | size_t | pSize | ) |
Truncates file to a specified size.
pSize | number of bytes to truncate to. |
static int Remove | ( | const char * | pFileName | ) | [static] |
Deletes the file.
pFileName | name of the file to remove |
static int Rename | ( | const char * | pFileName, |
const char * | pNewName | ||
) | [static] |
Rename file.
pFileName | Current file to rename. |
pNewName | New name of the file. |