File Content API
File Content API
The file content Lua API exposes JSLEE FileContentEvent
handling functionality for use within
the Lua script engine.
Functions
FileContentEvent:create (filePath, fileContents)
Description
Create a new instance of a FileContentEvent
.
Arguments
Argument | Comments |
---|---|
filePath |
The path to the file the content was originally read from. |
fileContents |
The content of the file as a string. |
Returns
Return | Type | Comments |
---|---|---|
FileContentEvent |
Object | The created FileContentEvent object. |
Example
local file = '/path/to/test.lua'
local lines = lines_from (file) -- custom function to read lines
fc = FileContentEvent:create (file, lines)
ok, result = JSLEE.send ("destination", fc)
if ok then
-- continue
FileContentEvent:getPath ()
Description
Returns the full file name and path of a FileContentEvent
object.
Arguments
None.
Returns
Return | Type | Comments |
---|---|---|
filePath |
String | The file name and path of the FileContentEvent object. |
Example
local path = message:getPath ()
FileContentEvent:setPath (filePath)
Description
Sets the file path of a FileContentEvent
object.
Arguments
Argument | Comments |
---|---|
filePath |
The file path to set. |
Returns
Nothing.
Example
message:setPath ("/path/to/file.html")
FileContentEvent:getContent ()
Description
Returns the file content of a FileContentEvent
object.
Arguments
None.
Returns
Return | Type | Comments |
---|---|---|
fileContent |
String | The file content of the FileContentEvent object. |
Example
local content = message:getContent ()
FileContentEvent:getFileName ()
Description
Returns the file name of a FileContentEvent
object.
Arguments
None.
Returns
Return | Type | Comments |
---|---|---|
fileName |
String | The file name of the FileContentEvent object. |
Example
local name = message:getFileName ()
FileContentEvent:setContent (fileContent)
Description
Sets the file content of a FileContentEvent
object.
Arguments
Argument | Comments |
---|---|
fileContent |
The file content to set. |
Returns
Nothing.
Example
message:setContent ("<h1>Hello World!</h1>")