|
AngelScript
|
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.
class file
{
int open(const string &in filename, const string &in mode);
int close();
int getSize() const;
bool isEndOfFile() const;
int readString(uint length, string &out str);
int readLine(string &out str);
int64 readInt(uint bytes);
uint64 readUInt(uint bytes);
float readFloat();
double readDouble();
int writeString(const string &in string);
int writeInt(int64 value, uint bytes);
int writeUInt(uint64 value, uint bytes);
int writeFloat(float value);
int writeDouble(double value);
int getPos() const;
int setPos(int pos);
int movePos(int delta);
bool mostSignificantByteFirst;
}
file f;
// Open the file in 'read' mode
if( f.open("file.txt", "r") >= 0 )
{
// Read the whole file into the string buffer
string str;
f.readString(f.getSize(), str);
f.close();
}