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): FileExample
file_fromPath("/home/user/data.txt") // returns a file objectCreate
| Input | A file. |
|---|---|
| Output | True if the file was created, false otherwise. |
Signature
file_create(a: File): BooleanExample
file_create(file_fromPath("new.txt")) // returns true if successfulRead
| Input | A file. |
|---|---|
| Output | The content of the file as a string. |
Signature
file_read(a: File): StringExample
file_read(file_fromPath("data.txt")) // returns the file contentsWrite
| 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): BooleanExample
file_write(file_fromPath("data.txt"), "hello") // returns true if successfulAppend
| Input | A file and content to append. |
|---|---|
| Output | True if the content was appended, false otherwise. |
Signature
file_append(a: File, b: String): BooleanExample
file_append(file_fromPath("log.txt"), "new line") // returns true if successfulExists
| Input | A file. |
|---|---|
| Output | True if the file exists, false otherwise. |
Signature
file_exists(a: File): BooleanExample
file_exists(file_fromPath("data.txt")) // returns true if it existsDelete
| Input | A file. |
|---|---|
| Output | True if the file was deleted, false otherwise. |
Signature
file_delete(a: File): BooleanExample
file_delete(file_fromPath("old.txt")) // returns true if successfulCopy
| Input | Two files. |
|---|---|
| Output | True if the file was copied, false otherwise. |
Signature
file_copy(a: File, b: File): BooleanExample
file_copy(file_fromPath("a.txt"), file_fromPath("b.txt")) // returns true if successfulMove
| Input | Two files. |
|---|---|
| Output | True if the file was moved, false otherwise. |
Signature
file_move(a: File, b: File): BooleanExample
file_move(file_fromPath("old.txt"), file_fromPath("new.txt")) // returns true if successfulRename
| Input | A file and the new name. |
|---|---|
| Output | True if the file was renamed, false otherwise. |
Signature
file_rename(a: File, b: String): BooleanExample
file_rename(file_fromPath("old.txt"), "new.txt") // returns true if successfulLength
| Input | A file. |
|---|---|
| Output | The length of the file in bytes. |
Signature
file_length(a: File): NumberExample
file_length(file_fromPath("data.txt")) // returns the file size in bytesPath
| Input | A file. |
|---|---|
| Output | The path of the file as a string. |
Signature
file_path(a: File): StringExample
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): StringExample
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): StringExample
file_extension(file_fromPath("data.txt")) // returns "txt"Parent
| Input | A file. |
|---|---|
| Output | The parent directory of the file. |
Signature
file_parent(a: File): DirectoryExample
file_parent(file_fromPath("/home/user/data.txt")) // returns the "/home/user" directoryLast Modified
| Input | A file. |
|---|---|
| Output | The timestamp of when the file was last modified. |
Signature
file_lastModified(a: File): TimestampExample
file_lastModified(file_fromPath("data.txt")) // returns the modification timestamp