File API
From Fernseher
Jump to navigationJump to search
File is a built in class from SpiderMonkey, but its poorly documented. Going through the source code, it appears this is what we get for the interface.
Global properties of File:
- curdir (sp?):
Properties of File objects:
- length
- name
- parent
- size
...
Methods of File objects:
- new File([path])
- open()
- close()
- flush()
...
I've extended File to add an include and require and stuff for my Modjs:
- File.prototype.include(): Executes the contents of the File as a javascript script in place.
- File.prototype.require(): Executes the contents of the File as a javascript script in place, only if it has not already been executed as part of a require(). Keeps track by updating a property in the global File class object (required[])
- File.required[]: array of filenames that have already been executed by a require() call for the current script.
- File.prototype.execute(args array): Executes the File as with server.runCmd(File, args array) and returns the exit status