Fluid Common API

The Common API provides a number of utility functions to enhance existing interfaces such as table. It also adds the file interface.

The API can be loaded with the line:

require 'common'

Table Enhancements

table.sortByKeys()

table.sortByKeys(Table)

Sort all key values in Table for processing as paired k,v items. Intended for use in a for loop as follows:

for k,v in table.sortByKeys(the_table) do
   ...
end

table.toXML()

String = table.toXML(Table)

Parse the key-values of a table and produce an XML string.

File Interface

file.readAll()

content = file.readAll(Path)

Reads all content from Path and returns it as a string. An exception will be thrown if failure occurs for any reason.

file.isFolder()

exists = file.isFolder(Path)

Returns true if the Path string explicitly references a folder. No test is performed to confirm whether or not the path exists.

file.splitPath()

path, filename = file.splitPath(Path)

Splits the folder and filename out from a Path string, returning them as distinct values. For instance parasol:a/b/file.txt results in parasol:a/b/ and file.txt.

file.sanitisePath()

path = file.sanitisePath(Path)

Removes repeated folder separators from a string. For instance volume:a/b///c\\f.txt becomes volume:a/b/c\f.txt.