File.open

From FreeSWITCH Wiki
Jump to: navigation, search

Opens a file handle

Synopsis

open(mode)
  • mode - a comma seperated list of the file modes
    • read - open for reading
    • write - open for writing
    • readWrite - open for reading and writing
    • append - add to the end of a file
    • create - create the file if it doesnt exist
    • replace - replace the contents with new ones (truncate)
    • autoflush - auto flush the buffer when writing

Example

var fd = new File("/tmp/blah");
fd.open("read,write,create");
// Read output from an application
var fd = new File("|ls /home");
fd.open("read");
var result = fd.read("128");

See also