Functions for working with files and directories.
file | Functions for working with files and directories. |
FileException | Generic file error. |
FileException. | Indicates that a directory already exists when calling mkdir. |
FileException. | Indicates that a an attempt was made to create, or overwrite an existing file. |
FileException.Open | Indicates that an error occurred when opening a file. |
FileException. | Indicates that a path was not found. |
FileException. | Indicates that an operation was denied due to filesystem permissions. |
FileException. | Indicates that an error occurred while writing to a file. |
FileType | Various types of directory entries. |
FileInfo | Holds file information returned by getInfo. |
copy | Copies a file to a new destination. |
copyOverwriteIfExists | Copies a file to a new destination. |
delete | Delete a file. |
exists | Check to see whether a name exists in the filesystem. |
files | Given a path name, return an array containing the names of the files in that directory. |
getInfo | Given a file name, return the file information. |
isDirectory | Similar to exists, but only returns TRUE if the path actually is a directory. |
mkdir | Create a new directory with the given name. |
pathJoin | Join components of a path using the <Separator> characters appropriate for the OS. |
pathSplit | Split a path into directory and name parts. |
readBytes | Read the contents of a file into Bytes. |
readLines | Read the lines of a file into an array of Strings. |
removeDirectoryTree | Remove directory tree recursively. |
removeEmptyDirectory | Remove an empty directory. |
rename | Rename a file. |
symlink | Create a symlink named newlink that points to target. |
writeBytes | Write a complete file from data in Bytes. |
writeLines | Write a complete file from lines of text in an array. |
Indicates that a directory already exists when calling mkdir.
Holds file information returned by getInfo.
DECLARE NATIVE FUNCTION copy( filename: String, destination: String )
Copies a file to a new destination. If the destination file already exists, a FileException.Exists is raised, and the file is not copied.
copyOverwriteIfExists exists delete
TRY file.copy("LICENSE.txt", "tmp/Copy_of_LICENSE.txt") TRAP file.FileException.Exists DO print("File copy failed. Destination file already exists.") END TRY
DECLARE NATIVE FUNCTION copyOverwriteIfExists( filename: String, destination: String )
Copies a file to a new destination. If the destination file exists, it will be overwritten. If the destination file does not exist, it will be created.
file.copyOverwriteIfExists("LICENSE.txt", "tmp/Copy_of_LICENSE.txt")
DECLARE NATIVE FUNCTION delete( filename: String )
Delete a file. This function does not raise an exception if the file does not exist.
DECLARE NATIVE FUNCTION isDirectory( path: String ): Boolean
Similar to exists, but only returns TRUE if the path actually is a directory.
DECLARE NATIVE FUNCTION mkdir( path: String )
Create a new directory with the given name.
DECLARE NATIVE FUNCTION readBytes( filename: String ): Bytes
Read the contents of a file into Bytes.
DECLARE NATIVE FUNCTION readLines( filename: String ): Array<String>
Read the lines of a file into an array of Strings.
DECLARE NATIVE FUNCTION writeBytes( filename: String, data: Bytes )
Write a complete file from data in Bytes.
Create a new directory with the given name.
DECLARE NATIVE FUNCTION mkdir( path: String )
Copies a file to a new destination.
DECLARE NATIVE FUNCTION copy( filename: String, destination: String )
Copies a file to a new destination.
DECLARE NATIVE FUNCTION copyOverwriteIfExists( filename: String, destination: String )
Delete a file.
DECLARE NATIVE FUNCTION delete( filename: String )
Check to see whether a name exists in the filesystem.
DECLARE NATIVE FUNCTION exists( filename: String ): Boolean
Given a path name, return an array containing the names of the files in that directory.
DECLARE NATIVE FUNCTION files( path: String ): Array<String>
Similar to exists, but only returns TRUE if the path actually is a directory.
DECLARE NATIVE FUNCTION isDirectory( path: String ): Boolean
Join components of a path using the Separator characters appropriate for the OS.
FUNCTION pathJoin( first, second: String ): String
Split a path into directory and name parts.
FUNCTION pathSplit( path: String, OUT directory, name: String )
Read the contents of a file into Bytes.
DECLARE NATIVE FUNCTION readBytes( filename: String ): Bytes
Read the lines of a file into an array of Strings.
DECLARE NATIVE FUNCTION readLines( filename: String ): Array<String>
Remove directory tree recursively.
FUNCTION removeDirectoryTree( path: String )
Remove an empty directory.
DECLARE NATIVE FUNCTION removeEmptyDirectory( path: String )
Rename a file.
DECLARE NATIVE FUNCTION rename( oldname: String, newname: String )
Create a symlink named newlink that points to target.
DECLARE NATIVE FUNCTION symlink( target: String, newlink: String, targetIsDirectory: Boolean DEFAULT FALSE )
Write a complete file from data in Bytes.
DECLARE NATIVE FUNCTION writeBytes( filename: String, data: Bytes )
Write a complete file from lines of text in an array.
DECLARE NATIVE FUNCTION writeLines( filename: String, data: Array<String> )