OpenWGA 7.10 - TMLScript reference

WGA
Object:

WGA.File([folder,] filename | File-Object)

Description

Utility object to read and write file contents.

If called with filename (String) as argument the object is initialised with a file (or folder) with that name relative to the OpenWGA config folder. When called with a java.io.File object that file object will be used.

This object is available since version 7.7.2

WGA.File(folder, filename) is available since version 7.10.1

Retrieval WGA.File()
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Properties and methods
Name Purpose
append(text, [encoding]) Appends the content to the referenced file.
asString([encoding]) Returns the content of the referenced file as String
asXMLDocument([encoding]) Returns the content of the referenced file as DOM4J XML document.
cleanDir() Remove all files and subdirectories but does not delete the directory itself
copy(InputStream)
copy(WGDocument | TMLContext, attachmentname)
Copies filedata from an imput steam or content attachment to the file.
createDir() Creates a directory if it does not already exists
createZipStream() Creates a ZipStream object to generate zip files.
deleteDir() Deletes the directory and its content if it exists including the referenced directory itself.

See also cleanDir().

exists() Tests if a file or folder exists in the file system
file Gets (or sets) the wrapped java.io.File object
inputStream Gets the input stream of the wrapped java.io.File object
isDirectory() Tests if the wrapped java.io.File object is a directory.
isFile() Tests if the wrapped java.io.File object is a file.
list() Returns directory list as WGAFile objects including subdirectories
listFiles([filter]) List all files in the referenced folder optional filtered by a filter function.
listFolders([filter]) List all subfolders in the referenced folder optional filtered by a filter function.

Available since version 7.10.5

mimeType Gets the mime type of the wrapped java.io.File object
name Returns the name of the file
setPosixFilePermissions(permissions) Sets the file permissions for existing files.
write(text | XMLDocument, [encoding]) Writes the given content to the file.