This is currently only a basic foundation for a file object that will allow scripts to read and write files.
Register with RegisterScriptFile(asIScriptEngine*).
class CScriptFile { public: // Constructor CScriptFile(); // Memory management void AddRef(); void Release(); // Opening and closing file handles // mode = "r" -> open the file for reading int Open(const std::string &filename, const std::string &mode); int Close(); // Returns the size of the file int GetSize(); // Reads a specified number of bytes into the string CScriptString *ReadString(unsigned int length); };
class file
{
int open(const string &in filename, const string &in mode);
int close();
int getSize();
string @ readString(uint length);
}
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());
f.close();
}
1.5.6