Class File
This class is used to manipulate files in the Collector.
Defined in: file.js.
Constructor Attributes | Constructor Name and Description |
---|---|
File(fileName, mode)
Creates a File object which references an open file on the local system.
|
Method Attributes | Method Name and Description |
---|---|
close()
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.
|
isOpen()
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
|
readFile()
Reads an entire file into memory from the current position.
|
|
readLine()
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
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.
- 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