AngelScript
file object

Path: /sdk/add_on/scriptfile/

This object provides support for reading and writing files.

Register with RegisterScriptFile(asIScriptEngine*).

If you do not want to provide write access for scripts then you can compile the add on with the define AS_WRITE_OPS 0, which will disable support for writing. This define can be made in the project settings or directly in the header.

Public C++ interface

class CScriptFile
{
public:
// Constructor
CScriptFile();
// Memory management
void AddRef() const;
void Release() const;
// Opening and closing file handles
// mode = "r" -> open the file for reading
// mode = "w" -> open the file for writing (overwrites existing files)
// mode = "a" -> open the file for appending
int Open(const std::string &filename, const std::string &mode);
int Close();
// Returns the size of the file
int GetSize() const;
// Returns true if the end of the file has been reached
bool IsEOF() const;
// Reads a specified number of bytes into the string
std::string ReadString(unsigned int length);
// Reads to the next new-line character
std::string ReadLine();
// Reads a signed integer
asINT64 ReadInt(asUINT bytes);
// Reads an unsigned integer
asQWORD ReadUInt(asUINT bytes);
// Reads a float
float ReadFloat();
// Reads a double
double ReadDouble();
// Writes a string to the file
int WriteString(const std::string &str);
int WriteInt(asINT64 v, asUINT bytes);
int WriteUInt(asQWORD v, asUINT bytes);
int WriteFloat(float v);
int WriteDouble(double v);
// File cursor manipulation
int GetPos() const;
int SetPos(int pos);
int MovePos(int delta);
// Determines the byte order of the binary values (default: false)
// Big-endian = most significant byte first
bool mostSignificantByteFirst;
};

Public script interface

See also
file
asINT64
__int64 asINT64
64 bit integer
Definition: angelscript.h:620
asQWORD
unsigned __int64 asQWORD
64 bit unsigned integer
Definition: angelscript.h:619
asUINT
unsigned int asUINT
32 bit unsigned integer
Definition: angelscript.h:600