File
From FreeSWITCH Wiki
This chapter of documentation relates to the Mozilla Spidermonkey File Object. The Mozilla Spidermonkey File Object webpage does not have much documentation, so it is documented here. Anyone using Spidermonkey File Object is welcome to use this for their reference outside of FreeSwitch as well, since this is Mozillas code instead of anything specific to FreeSwitch.
In order to ensure that you have this you must have JS_HAS_FILE_OBJECT=1 in mozilla.build.sh when jslib is built (part of the source distribution). In future releases ((FreeSwitch]] should have this enabled by default, however testing to ensure this works on all platforms is being conducted and until that is complete it will not be by default. Note: the new build system appears to make it default now
Contents |
Description
The File object lets you manipulate files.
Synopsis
File(filename)
- filename - the filename including path to open
Note: if you put a | before the name it will execute a command and let you write to that command. If you put a | after the filename it will let you execute a command and read its output. The code prohibits both a pipe before and after the same command. If you want that you will have to open 2 files, one which is on a FIFO (mkfifo may be handy) and the other that is the program you wish to exec.
var fd = new File("| cat -v | lpr -h"); // might be interesting
var fd = new File("netstat -an|"); // might also be interesting
Example
fd = new File("/tmp/blah");
Methods
- File.open
- File.close
- File.remove
- File.copyTo
- File.renameTo
- File.flush
- File.seek
- File.read
- File.readln
- File.readAll
- File.write
- File.writeln
- File.writeAll
- File.list
- File.mkdir
- File.toString
- File.toURL
Properties
- File.length
- File.parent
- File.path
- File.name
- File.input -- stdin
- File.isDirectory
- File.isFile
- File.error -- stderr
- File.exists
- File.canRead
- File.canWrite
- File.canAppend
- File.canReplace
- File.isOpen
- File.type
- File.mode
- File.creationTime
- File.lastModified
- File.size
- File.hasRandomAccess
- File.hasAutoFlush
- File.position
- File.isNative
- File.output -- stdout
