Interface IFileSystem
interface IFileSystem
Extends com.amazon.apmf.IStandard
Defines common functionality for accessing and manipulating files and directories.
Methods
openFile()
Opens a file with the specified mode.IFile*openFile(stringpath,OpenModemode)
Parameters
path
string — Required
The path of the file to open.
mode
OpenMode — Required
The mode to open the file in.
Returns
IFile*
The handle to the opened file.
Throws
NotFoundError— when a file is not found.IsADirectoryError— when the path refers to a directory.PermissionDeniedError— when permissions do not allow an operation to be completed.
removeFile()
Deletes a file at the path.voidremoveFile(stringpath)
Parameters
path
string — Required
The path of the file to delete.
Throws
NotFoundError— when a file to delete is not found.IsADirectoryError— when the path refers to a directory.PermissionDeniedError— when permissions do not allow an operation to be completed.IoError— if an error occurs during deletion.
removeDir()
Deletes a directory at the path.voidremoveDir(stringpath)
Parameters
path
string — Required
The path of the directory to delete.
Throws
NotFoundError— when a directory to delete is not found.NotADirectoryError— when the path does not refer to a directory.NotEmptyError— when a directory to delete is non-empty.PermissionDeniedError— when permissions do not allow an operation to be completed.IoError— if an error occurs during deletion.
removeDirAll()
Deletes a directory at the path and all its content.voidremoveDirAll(stringpath)
Parameters
path
string — Required
The path of the directory to delete.
Throws
NotFoundError— when a directory is not found.NotADirectoryError— when the path does not refer to a directory.PermissionDeniedError— when permissions do not allow an operation to be completed.IoError— if an error occurs during deletion.
readFileAsString()
Reads the entire content of a text file into a string.stringreadFileAsString(stringpath,stringencoding)
Parameters
path
string — Required
The path to the file.
encoding
string — Required
The encoding to use when reading the file.
Returns
string
The content of the file as a UTF-8 string.
Throws
NotFoundError— when a file to read is not found.IsADirectoryError— when the path refers to a directory.PermissionDeniedError— when permissions do not allow an operation to be completed.IoError— if an error occurs during reading.
writeStringToFile()
Writes a string to a text file.i32writeStringToFile(stringpath,stringcontent,stringencoding)
Parameters
path
string — Required
The path to the file.
content
string — Required
The string content to write.
encoding
string — Required
The encoding to use when writing the file.
Returns
i32
The number of bytes written to the file
Throws
AlreadyExistsError— when an attempt is made to write to file that already exists.IsADirectoryError— when the path refers to a directory.PermissionDeniedError— when permissions do not allow an operation to be completed.IoError— if an error occurs during writing.
getEntries()
Gets directory entries for the given path.IDirEntry*[]getEntries(stringpath)
Parameters
path
string — Required
The path to the directory.
Returns
IDirEntry*[]
Array of IDirEntry objects representing each entry.
Throws
NotFoundError— when a directory is not found.NotADirectoryError— when the path does not refer to a directory.

