Skip to content

File

An object representing a file


properties

Path : string

The absolute path to the file.

Size : number

The size of the file in bytes.

Created : DateTime

The time the file was created.

Accessed : DateTime

The time the file was accessed.

Modified : DateTime

The time the file was modified.

Exists : boolean

Whether or not the file exists yet.

Extension : boolean

The file extension of the file.


methods

Read -> number

File:Read(): buffer
Reads the file as a buffer of unsigned 8 bit integers.

Write -> number

File:Write(contents : buffer) : File
Writes the contents of the file. Returns itself.

Append -> number

File:Append(contents : buffer) : File
Appends the given contents onto the end of the contents of the file. Returns itself.

Delete -> number

File:Delete()
Deletes the file.

Move -> number

File:Move(path: string) : File
Moves the file to a different location. Returns itself.

Copy -> number

File:Copy(path: string) : File
Copies the file to a new location. Returns the copied file.


metamethods

__tostring -> string

Converts the file into a string in the format file [Size] [Path]