Class Index | File Index

Classes


Class File

This class is used to manipulate files in the Collector.
Defined in: file.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
File(fileName, mode)
Creates a File object which references an open file on the local system.
Method Summary
Method Attributes Method Name and Description
 
Closes the file.
<static>  
File.create(file)
Creates a file, including all containing directories as necessary.
<static>  
File.glob(dir, glob)
Fetches a list of files that matches a standard file glob pattern.
 
Checks if the file is currently opened in read or write mode.
<static>  
File.modTime(fileName)
Gets the time the file was last modified, in milliseconds since midnight Jan 1 '70
 
Reads an entire file into memory from the current position.
 
Reads a line from the file.
<static>  
File.remove(filename)
Deletes a file.
<static>  
File.rename(fromName, toName)
Renames a file.
 
writeLine(line, addLnSep)
Writes a line to the file and optionally appends a line separator
Class Detail
File(fileName, mode)
Creates a File object which references an open file on the local system. The path to the file must be absolute, and the file must be located within the ESEC_HOME/data or ESEC_HOME/log directories (use the File Connector or File Integrator to read/write files outside ESEC_HOME).

Example:

var myFile=new File(instance.CONFIG.collDir + "/myfile.mine");
Several pre-defined variables are provided to assist in locating files:
  • instance.CONFIG.esecDir - ESEC_HOME directory (with slash)
  • instance.CONFIG.logDir - the Sentinel log directory (ESEC_HOME/log)
  • instance.CONFIG.commonDir - Storage area for Collector common resource files
  • instance.CONFIG.collDir - the directory in which the Collector plug-in is unpacked, along with any auxiliary files
Parameters:
{String} fileName
The absolute path and file name to open
{String} mode
The mode to open the file in, use "w" or "W" for write mode
Method Detail
close()
Closes the file.

<static> {Boolean} File.create(file)
Creates a file, including all containing directories as necessary. The path to the file must be absolute, and must be contained within the Sentinel directory /var, or /tmp (on Windows, since there is no standard "variable data" area, create a.
Parameters:
{Object} file
The file to create
Returns:
{Boolean} False if the file could not be created.

<static> {String[]} File.glob(dir, glob)
Fetches a list of files that matches a standard file glob pattern.
Parameters:
{String} dir
{Regular Expression literal} glob
Returns:
{String[]} array of file's absolute paths or undefined if the dir is invalid

{boolean} isOpen()
Checks if the file is currently opened in read or write mode.
Returns:
{boolean} true if file was opened ; false if file closed .

<static> {Number} File.modTime(fileName)
Gets the time the file was last modified, in milliseconds since midnight Jan 1 '70
Parameters:
{Object} fileName
The name of the file to get the mod time of
Returns:
{Number} Number of milliseconds since midnight Jan 1 '70

{String} readFile()
Reads an entire file into memory from the current position. This method is limited to read a maximum of 512k characters (i.e 524288 characters).
Returns:
{String} The file contents as single string. else 'undefined' if it fails due to any reason.

{String} readLine()
Reads a line from the file.
Returns:
{String}

<static> {Boolean} File.remove(filename)
Deletes a file. The path to the files must be absolute and must be contained within the ESEC_HOME directory.
Parameters:
{String} filename
Returns:
{Boolean} status of file remove

<static> {Boolean} File.rename(fromName, toName)
Renames a file. The path to the files must be absolute and must be contained within the ESEC_HOME directory.
Parameters:
{String} fromName
- soure file name
{String} toName
- destination file name
Returns:
{Boolean} status of file rename.

{Boolean} writeLine(line, addLnSep)
Writes a line to the file and optionally appends a line separator
Parameters:
{String} line
to be written
{Boolean} addLnSep
boolean flag that tells to append line seperator or not
Returns:
{Boolean} Status of the write attempt

©2008
Documentation generated by JsDoc Toolkit 2.0.2 on Thu Oct 07 2010 07:23:17 GMT-0400 (EDT)