Open Game Engine 2D API
 All Functions Variables
Functions
File

Functions

int OGE_FileSize (string sFileName)
 Get the size of a file.
bool OGE_FileExists (string sFileName)
 Check if the file exists or not.
bool OGE_CreateEmptyFile (string sFileName)
 Create an empty file.
bool OGE_RemoveFile (string sFileName)
 Remove a file.
int OGE_OpenFile (string sFileName, bool bTryCreate)
 Open a file.
int OGE_CloseFile (int iFileId)
 Close a file.
int OGE_SaveFile (int iFileId)
 Save a file.
bool OGE_GetFileEof (int iFileId)
 Check if it has reached the end of the file.
int OGE_GetFileReadPos (int iFileId)
 Get current reading position of the file.
int OGE_SetFileReadPos (int iFileId, int iPos)
 Set current reading position of the file.
int OGE_SetFileReadPosFromEnd (int iFileId, int iPos)
 Set current reading position by setting the position(offset) relative to the end of the file.
int OGE_GetFileWritePos (int iFileId)
 Get current writing position of the file.
int OGE_SetFileWritePos (int iFileId, int iPos)
 Set current writing position of the file.
int OGE_SetFileWritePosFromEnd (int iFileId, int iPos)
 Set current writing position by setting the position(offset) relative to the end of the file.
char OGE_ReadFileByte (int iFileId)
 Read a byte from the file.
int OGE_ReadFileInt (int iFileId)
 Read an integer from the file.
double OGE_ReadFileFloat (int iFileId)
 Read a floating-point value from the file.
int OGE_ReadFileBuf (int iFileId, int iLen, int iBufId)
 Copy bytes from the file to a buffer.
string OGE_ReadFileStr (int iFileId, int iLen)
 Read a string from the file.
int OGE_WriteFileByte (int iFileId, char value)
 Write a byte into the file.
int OGE_WriteFileInt (int iFileId, int value)
 Write an integer into the file.
int OGE_WriteFileFloat (int iFileId, double value)
 Write a floating-point value into the file.
int OGE_WriteFileBuf (int iFileId, int buf, int len)
 Copy bytes from a buffer to the file.
int OGE_WriteFileStr (int iFileId, string value)
 Write a string into the file.

Function Documentation

int OGE_CloseFile ( int  iFileId)

Close a file.

Parameters:
[in]iFileIdThe ID of the file
Returns:
Return a non-negative number if succeed
bool OGE_CreateEmptyFile ( string  sFileName)

Create an empty file.

Parameters:
[in]sFileNameThe file path
Returns:
Succeed or not
bool OGE_FileExists ( string  sFileName)

Check if the file exists or not.

Parameters:
[in]sFileNameThe file path
Returns:
Returns true if the file exists
int OGE_FileSize ( string  sFileName)

Get the size of a file.

Parameters:
[in]sFileNameThe file path
Returns:
The file size
bool OGE_GetFileEof ( int  iFileId)

Check if it has reached the end of the file.

Parameters:
[in]iFileIdThe ID of the file
Returns:
Reached the end or not
int OGE_GetFileReadPos ( int  iFileId)

Get current reading position of the file.

Parameters:
[in]iFileIdThe ID of the file
Returns:
Current reading position
int OGE_GetFileWritePos ( int  iFileId)

Get current writing position of the file.

Parameters:
[in]iFileIdThe ID of the file
Returns:
Current writing position
int OGE_OpenFile ( string  sFileName,
bool  bTryCreate 
)

Open a file.

Parameters:
[in]sFileNameThe file path
[in]bTryCreateCreate or not if the file does not exist
Returns:
The ID of the file
int OGE_ReadFileBuf ( int  iFileId,
int  iLen,
int  iBufId 
)

Copy bytes from the file to a buffer.

Parameters:
[in]iFileIdThe ID of the file
[in]iLenThe count of the bytes
[in]iBufIdThe ID of the buffer
Returns:
Return a non-zero number if succeed
char OGE_ReadFileByte ( int  iFileId)

Read a byte from the file.

Parameters:
[in]iFileIdThe ID of the file
Returns:
The value of the byte
double OGE_ReadFileFloat ( int  iFileId)

Read a floating-point value from the file.

Parameters:
[in]iFileIdThe ID of the file
Returns:
The floating-point value
int OGE_ReadFileInt ( int  iFileId)

Read an integer from the file.

Parameters:
[in]iFileIdThe ID of the file
Returns:
The value of the integer
string OGE_ReadFileStr ( int  iFileId,
int  iLen 
)

Read a string from the file.

Parameters:
[in]iFileIdThe ID of the file
[in]iLenThe length of the string
Returns:
The string
bool OGE_RemoveFile ( string  sFileName)

Remove a file.

Parameters:
[in]sFileNameThe file path
Returns:
Succeed or not
int OGE_SaveFile ( int  iFileId)

Save a file.

Parameters:
[in]iFileIdThe ID of the file
Returns:
Return a non-negative number if succeed
int OGE_SetFileReadPos ( int  iFileId,
int  iPos 
)

Set current reading position of the file.

Parameters:
[in]iFileIdThe ID of the file
[in]iPosThe reading position
Returns:
Current reading position
int OGE_SetFileReadPosFromEnd ( int  iFileId,
int  iPos 
)

Set current reading position by setting the position(offset) relative to the end of the file.

Parameters:
[in]iFileIdThe ID of the file
[in]iPosThe position relative to the end of the file
Returns:
Current reading position of the file
int OGE_SetFileWritePos ( int  iFileId,
int  iPos 
)

Set current writing position of the file.

Parameters:
[in]iFileIdThe ID of the file
[in]iPosThe writing position
Returns:
Current writing position
int OGE_SetFileWritePosFromEnd ( int  iFileId,
int  iPos 
)

Set current writing position by setting the position(offset) relative to the end of the file.

Parameters:
[in]iFileIdThe ID of the file
[in]iPosThe position relative to the end of the file
Returns:
Current writing position of the file
int OGE_WriteFileBuf ( int  iFileId,
int  buf,
int  len 
)

Copy bytes from a buffer to the file.

Parameters:
[in]iFileIdThe ID of the file
[in]bufThe ID of the buffer
[in]lenThe count of the bytes
Returns:
Return a non-negative number if succeed
int OGE_WriteFileByte ( int  iFileId,
char  value 
)

Write a byte into the file.

Parameters:
[in]iFileIdThe ID of the file
[in]valueThe value of the byte
Returns:
Return a non-negative number if succeed
int OGE_WriteFileFloat ( int  iFileId,
double  value 
)

Write a floating-point value into the file.

Parameters:
[in]iFileIdThe ID of the file
[in]valueThe floating-point value
Returns:
Return a non-negative number if succeed
int OGE_WriteFileInt ( int  iFileId,
int  value 
)

Write an integer into the file.

Parameters:
[in]iFileIdThe ID of the file
[in]valueThe value of the integer
Returns:
Return a non-negative number if succeed
int OGE_WriteFileStr ( int  iFileId,
string  value 
)

Write a string into the file.

Parameters:
[in]iFileIdThe ID of the file
[in]valueThe string
Returns:
Return a non-negative number if succeed