new FileIO()
METHODS
-
async appendTextFile(filePath, additionalContent, isPathRelative (opt)) returns {IncrCommsResponseObject}
-
Appends text content to the text file at the given file path. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description filePathstring The relative or absolute path to the file in question.
additionalContentstring This is the text content that will be written in the file.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
Returns:
IncrCommsResponseObject -
async compress(sourcePath, isPathRelative (opt)) returns {IncrCommsResponseObject}
-
Compresses the given file or directory into a zip file. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description sourcePathstring The relative or absolute path to the file or directory in question. If a directory path is provided, the directory must contain at least one file or an error will be encountered.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
Returns:
IncrCommsResponseObject -
async copyTo(sourcePath, destinationPath, isPathRelative (opt), newName (opt)) returns {IncrCommsResponseObject}
-
Copies the provided file or directory into the designated directory, with an option to rename the item while copying. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description sourcePathstring The relative or absolute path to the source item.
destinationPathstring The relative or absolute path for the destination directory.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
newNamestring <optional>
The new name (not including the path) of the item you wish to rename. If "" is provided, then no rename occurs. [DEFAULT: ""].
Returns:
IncrCommsResponseObject -
async createDirectory(directoryPath, isPathRelative (opt)) returns {IncrCommsResponseObject}
-
Returns an IncrCommsResponseObject with a '.payload' string containing the contents of the text file at the given path. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description directoryPathstring The relative or absolute path to the directory in question.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
Returns:
IncrCommsResponseObject -
async decompress(sourcePath, isPathRelative (opt)) returns {IncrCommsResponseObject}
-
Decompresses the zip file at the given path into its source format. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description sourcePathstring The relative or absolute path to the file or directory in question.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
Returns:
IncrCommsResponseObject -
async delete(path, isPathRelative (opt)) returns {IncrCommsResponseObject}
-
Deletes the provided file or directory. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description pathstring The relative or absolute path of the item to delete.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
Returns:
IncrCommsResponseObject -
async directoryExists(directoryPath, isPathRelative (opt)) returns {IncrCommsResponseObject}
-
Returns an IncrCommsResponseObject with a '.payload' bool stating if the directory at the given path exists. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description directoryPathstring This is the relative or absolute path to the directory in question.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
Returns:
IncrCommsResponseObject -
async fileExists(filePath, isPathRelative (opt)) returns {IncrCommsResponseObject}
-
Returns an IncrCommsResponseObject with a '.payload' bool stating if the file at the given path exists. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description filePathstring This is the relative or absolute path to the file in question.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
Returns:
IncrCommsResponseObject -
async getDirectoryContents(directoryPath, isPathRelative (opt), recurseSubdirectories (opt), includeHiddenFiles (opt)) returns {Array.<PathInfo>}
-
Returns an IncrCommsResponseObject with a '.payload' array containing the paths to the directories and files within the given directory. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description directoryPathstring This is the relative or absolute path to the directory in question.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
recurseSubdirectoriesboolean <optional>
Bool stating if list of paths returned should include all sub-directories. [DEFAULT: false]
includeHiddenFilesboolean <optional>
Bool stating if list of paths returned should include hidden files. [DEFAULT: false]
Returns:
Array.<PathInfo> -
async moveTo(sourcePath, destinationPath, isPathRelative (opt), newName (opt)) returns {IncrCommsResponseObject}
-
Moves the provided file or directory into the designated directory, with an option to rename the item while moving. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description sourcePathstring The relative or absolute path to the source item.
destinationPathstring The relative or absolute path for the destination directory.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
newNamestring <optional>
The new name (not including the path) of the item you wish to rename. If "" is provided, then no rename occurs. [DEFAULT: ""].
Returns:
IncrCommsResponseObject -
async readFileBase64(filePath, isPathRelative (opt)) returns {IncrCommsResponseObject}
-
Returns an IncrCommsResponseObject with a '.payload' string containing the contents of the file at the given path in Base64 format. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description filePathstring The relative or absolute path to the file in question.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
Returns:
IncrCommsResponseObject -
async readTextFile(filePath, isPathRelative (opt)) returns {IncrCommsResponseObject}
-
Returns an IncrCommsResponseObject with a '.payload' string containing the contents of the text file at the given path. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description filePathstring The relative or absolute path to the file in question.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
Returns:
IncrCommsResponseObject -
async rename(path, newName, isPathRelative (opt)) returns {IncrCommsResponseObject}
-
Renames the file or folder at the given path. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description pathstring The relative or absolute path to the file in question.
newNamestring The new name (not including the path) of the item you wish to rename.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
Returns:
IncrCommsResponseObject -
async writeFileFromBase64(filePath, base64, isPathRelative (opt)) returns {IncrCommsResponseObject}
-
Writes a file from a base64 string. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description filePathstring The relative or absolute path to the file in question.
base64string The source base64 string to write the file from.
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
Returns:
IncrCommsResponseObject -
async writeTextFile(filePath, fileContent (opt), isPathRelative (opt)) returns {IncrCommsResponseObject}
-
Writes text content to a file at the given path. If an error is encountered, related information will be stored in the '.error' member of the returned IncrCommsResponseObject. This function is asynchronous will return a promise if not 'awaited'.
Parameters:
Name Type Attributes Default Description filePathstring The relative or absolute path to the file in question.
fileContentstring <optional>
This is the text content that will be written in the file. [DEFAULT: ""]
isPathRelativeboolean <optional>
Bool stating if the given path is relative to the project path or an absolute path. If an absolute path is used that is outside of the project directory, the 'allowUniversalFileIO' item in application settings must be set to true. [DEFAULT: true]
Returns:
IncrCommsResponseObject