file object

Path: /sdk/add_on/scriptfile/

This is currently only a basic foundation for a file object that will allow scripts to read and write files.

Register with RegisterScriptFile(asIScriptEngine*).

Public C++ interface

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);
};

Public script interface

  class file
  {
    int open(const string &in filename, const string &in mode);
    int close();
    int getSize();
    string @ readString(uint length);
  }

Script example

  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();
  }

Generated on Sun Dec 14 10:31:06 2008 for AngelScript by  doxygen 1.5.6