File

Methods
22
Fields
None

Getting one

File.new(…)
ClientPaths.CLIENT_DIR
ClientPaths.CACHE_DIR

Methods

MethodReturnsDescription
exists()booleanWhether a file or directory is there.
isFile()booleanWhether it is a file.
isDirectory()booleanWhether it is a directory (the plugin's directory always is).
mkdirs()booleanCreate the directory and its parents; true when it was created.
mkdir()booleanCreate the directory when its parent exists; true when it was created.
delete()booleanDelete the file, or the directory when it is empty; true when it went.
length()numberThe file's size in bytes, 0 when there is none.
lastModified()numberWhen it last changed, ms since the epoch; 0 when there is none.
renameTo(File)booleanMove the file to dest; true when it moved.
list(){string}?The names directly in this directory, or nil when it is not one.
listFiles(){File}?The files directly in this directory, or nil when it is not one.
getName()stringThe last component (.bentobox for the plugin's directory).
getPath()stringThe path as text, .bentobox\....
getParent()string?The parent's path as text, or nil for the plugin's directory.
getParentFile()File?The parent, or nil for the plugin's directory.
equals(any)booleanWhether obj is a File of the same path.
toString()stringThe path as text, .bentobox\....
readText()stringThe whole file as text (UTF-8, a byte order mark dropped). A missing file is FileNotFoundException.
writeText(string)()Replace the file with text (UTF-8) at once, atomically, under the plugin's quota; parent directories are made.
readBytes()stringThe whole file's bytes, as a Luau string (any bytes). A missing file is FileNotFoundException.
writeBytes(string)()Replace the file with bytes (a Luau string, any bytes) at once, atomically, under the plugin's quota; parent directories are made.
new(File?, string)File(File?, string) -> File: child inside parent (nil parent: child alone).
new(string)File
new(string?, string)File

Returned by

MethodReturnsDescription
FileClass.newFile(File?, string) -> File: child inside parent (nil parent: child alone).

Method details

exists

exists: (File) -> boolean

Whether a file or directory is there.

isFile

isFile: (File) -> boolean

Whether it is a file.

isDirectory

isDirectory: (File) -> boolean

Whether it is a directory (the plugin's directory always is).

mkdirs

mkdirs: (File) -> boolean

Create the directory and its parents; true when it was created.

mkdir

mkdir: (File) -> boolean

Create the directory when its parent exists; true when it was created.

delete

delete: (File) -> boolean

Delete the file, or the directory when it is empty; true when it went.

length

length: (File) -> number

The file's size in bytes, 0 when there is none.

lastModified

lastModified: (File) -> number

When it last changed, ms since the epoch; 0 when there is none.

renameTo

renameTo: (File, File) -> boolean

Move the file to dest; true when it moved.

list

list: (File) -> {string}?

The names directly in this directory, or nil when it is not one.

listFiles

listFiles: (File) -> {File}?

The files directly in this directory, or nil when it is not one.

getName

getName: (File) -> string

The last component (.bentobox for the plugin's directory).

getPath

getPath: (File) -> string

The path as text, .bentobox\....

getParent

getParent: (File) -> string?

The parent's path as text, or nil for the plugin's directory.

equals

equals: (File, any) -> boolean

Whether obj is a File of the same path.

toString

toString: (File) -> string

The path as text, .bentobox\....

readText

readText: (File) -> string

The whole file as text (UTF-8, a byte order mark dropped). A missing file is FileNotFoundException.

writeText

writeText: (File, string) -> ()

Replace the file with text (UTF-8) at once, atomically, under the plugin's quota; parent directories are made.

readBytes

readBytes: (File) -> string

The whole file's bytes, as a Luau string (any bytes). A missing file is FileNotFoundException.

writeBytes

writeBytes: (File, string) -> ()

Replace the file with bytes (a Luau string, any bytes) at once, atomically, under the plugin's quota; parent directories are made.

new

new: ((File?, string) -> File) & ((string) -> File) & ((string?, string) -> File)

(File?, string) -> File: child inside parent (nil parent: child alone).

(string) -> File: The file at pathname, relative to the plugin's directory (/ or \; a .bentobox\... text a File printed is accepted).

(string?, string) -> File: child inside the directory parent names.