Difference between revisions of "File API"

From Fernseher
Jump to navigationJump to search
(New page: 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...)
 
Line 22: Line 22:
*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.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.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

Revision as of 17:01, 20 January 2009

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:

  • 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