Skip to content
Reference > Classes

FileSystem

Definition

FileSystem var = .... ;

Extends

Extended By

None

Description

Represents the file system on which the AMI Webserver is running.

Method Summary

Owner Name Return Type Description
FileSystem getAmiFilePath(filePath) String Converts and returns a path to AMI default path, which uses forward slash.
Object getClassName() String Returns the string name of this object's class type.
FileSystem getWorkingDirectory() String Returns the path of the working directory (the root file).
FileSystem listFiles(relativePathToDirectory) Table Returns a Table containing the files and file details of all files in supplied directory. Details include: name, size, type, hidden, executable, readable, writeable, modifiedOn.
FileSystem readBinaryFile(fileName) Binary Returns the binary data of supplied file or null if the file does not exist or is not readable. The filename should be relative to the root folder of AMI.
FileSystem readFile(fileNamePath) String Returns the contents of supplied file or null if file does not exist or is not readable. The filename should be relative to the root folder of AMI.
Object toJson() String Returns a json representation of this object.
FileSystem writeBinaryFile(file, data, shouldAppend) Boolean Writes the data to disk. If shouldAppend is true and if file exists then data is appended, otherwise file is overridden. The filename should be formatted as either an absolute path or a relative path. Returns true on success.
FileSystem writeFile(file, data, shouldAppend) Boolean Writes the data to disk. If shouldAppend is true and if file exists then data is appended, otherwise file is overridden. Returns true on success.

Method Definitions


getAmiFilePath(filePath)

String FileSystem::getAmiFilePath(String filePath)

Description

Converts and returns a path to AMI default path, which uses forward slash.

Parameter Definition

Name Type Description
filePath String 

getWorkingDirectory()

String FileSystem::getWorkingDirectory()

Description

Returns the path of the working directory (the root file).


listFiles(relativePathToDirectory)

Table FileSystem::listFiles(String relativePathToDirectory)

Description

Returns a Table containing the files and file details of all files in supplied directory. Details include: name, size, type, hidden, executable, readable, writeable, modifiedOn.

Parameter Definition

Name Type Description
relativePathToDirectory String  the path to the directory under the AMI root directory. Ex: resources

readBinaryFile(fileName)

Binary FileSystem::readBinaryFile(String fileName)

Description

Returns the binary data of supplied file or null if the file does not exist or is not readable. The filename should be relative to the root folder of AMI.

Parameter Definition

Name Type Description
fileName String  the path to the file plus the full file name. Ex: resources/myfile.txt

readFile(fileNamePath)

String FileSystem::readFile(String fileNamePath)

Description

Returns the contents of supplied file or null if file does not exist or is not readable. The filename should be relative to the root folder of AMI.

Parameter Definition

Name Type Description
fileNamePath String  the path to the file plus the full file name. Ex: resources/myfile.txt

writeBinaryFile(file,data,shouldAppend)

Boolean FileSystem::writeBinaryFile(String file, Binary data, Boolean shouldAppend)

Description

Writes the data to disk. If shouldAppend is true and if file exists then data is appended, otherwise file is overridden. The filename should be formatted as either an absolute path or a relative path. Returns true on success.

Parameter Definition

Name Type Description
file String 
data Binary 
shouldAppend Boolean 

writeFile(file,data,shouldAppend)

Boolean FileSystem::writeFile(String file, String data, Boolean shouldAppend)

Description

Writes the data to disk. If shouldAppend is true and if file exists then data is appended, otherwise file is overridden. Returns true on success.

Parameter Definition

Name Type Description
file String 
data String 
shouldAppend Boolean