Reference

File

Note: File functions are not implemented on the web platform.

From path

Input A string.
Output A file pointing to the given path.

Signature

file_fromPath(a: String): File

Example

file_fromPath("/home/user/data.txt") // returns a file object

Create

Input A file.
Output True if the file was created, false otherwise.

Signature

file_create(a: File): Boolean

Example

file_create(file_fromPath("new.txt")) // returns true if successful

Read

Input A file.
Output The content of the file as a string.

Signature

file_read(a: File): String

Example

file_read(file_fromPath("data.txt")) // returns the file contents

Write

Input A file and a content.
Output True if the file was written with the content, false otherwise.

Signature

file_write(a: File, b: String): Boolean

Example

file_write(file_fromPath("data.txt"), "hello") // returns true if successful

Append

Input A file and content to append.
Output True if the content was appended, false otherwise.

Signature

file_append(a: File, b: String): Boolean

Example

file_append(file_fromPath("log.txt"), "new line") // returns true if successful

Exists

Input A file.
Output True if the file exists, false otherwise.

Signature

file_exists(a: File): Boolean

Example

file_exists(file_fromPath("data.txt")) // returns true if it exists

Delete

Input A file.
Output True if the file was deleted, false otherwise.

Signature

file_delete(a: File): Boolean

Example

file_delete(file_fromPath("old.txt")) // returns true if successful

Copy

Input Two files.
Output True if the file was copied, false otherwise.

Signature

file_copy(a: File, b: File): Boolean

Example

file_copy(file_fromPath("a.txt"), file_fromPath("b.txt")) // returns true if successful

Move

Input Two files.
Output True if the file was moved, false otherwise.

Signature

file_move(a: File, b: File): Boolean

Example

file_move(file_fromPath("old.txt"), file_fromPath("new.txt")) // returns true if successful

Rename

Input A file and the new name.
Output True if the file was renamed, false otherwise.

Signature

file_rename(a: File, b: String): Boolean

Example

file_rename(file_fromPath("old.txt"), "new.txt") // returns true if successful

Length

Input A file.
Output The length of the file in bytes.

Signature

file_length(a: File): Number

Example

file_length(file_fromPath("data.txt")) // returns the file size in bytes

Path

Input A file.
Output The path of the file as a string.

Signature

file_path(a: File): String

Example

file_path(file_fromPath("/home/user/data.txt")) // returns "/home/user/data.txt"

Name

Input A file.
Output The name of the file as a string.

Signature

file_name(a: File): String

Example

file_name(file_fromPath("/home/user/data.txt")) // returns "data.txt"

Extension

Input A file.
Output The extension of the file as a string.

Signature

file_extension(a: File): String

Example

file_extension(file_fromPath("data.txt")) // returns "txt"

Parent

Input A file.
Output The parent directory of the file.

Signature

file_parent(a: File): Directory

Example

file_parent(file_fromPath("/home/user/data.txt")) // returns the "/home/user" directory

Last Modified

Input A file.
Output The timestamp of when the file was last modified.

Signature

file_lastModified(a: File): Timestamp

Example

file_lastModified(file_fromPath("data.txt")) // returns the modification timestamp