Filesystem
Documentation of the filesystem library.
The filesystem library allows for interacting with filesystem components more easily and properly processing paths.
filesystem.absolutePath(path: string): string, stringReturns the address of the filesystem component thatpathleads to and the absolute path in said filesystem component.filesystem.canonical(path: string): stringReturns the canonical path ofpath(one containing no special segments like . or ..). For example, the canonical path of/home/../halyde/./appsis/halyde/apps.filesystem.concat(path1: string, path2: string): stringReturns the result of concatenating thepath1andpath2together.filesystem.copy(fromPath: string, toPath: string): boolean or nil, stringCopies the file atfromPathtotoPath.toPathmust contain the file's name. Returnsniland an error message if an error occurred.filesystem.exists(path: string): booleanReturns whether there is an object atpathor not.filesystem.isDirectory(path: string): booleanReturns whether the object atpathis a directory or not.filesystem.list(path: string): table or nil, stringReturns a table of all objects atpath, if it is a directory. Directories are suffixed with/. Returnsniland an error message if an error occurred.filesystem.makeDirectory(path: string): boolean or nil, stringCreates a directory atpath. Returnsniland an error message if an error occurred.filesystem.open(path: string, [mode: string]): table or nil, stringOpens a file atpathfor reading/writing.modedefaults tor. Possible modes arer,rb,w,wb,aandab. Returns a file stream - a table with 3 functions. Returnsniland an error message if an error occurred.stream:read(amount: number): string or nil, stringTries to read the specified number of bytes from the file stream. Returnsniland an error message if an error occurred.stream:write(data: string): boolean or nil, stringWritesdatato the file stream. Returnsniland an error message if an error occurred.stream:readBytes(n: number): number or nilReturns the unsigned integer of a specific number of bytes, in big endian. Ifnis 1, then it will return one byte from the file as a number.stream:readUnicodeChar(): stringReads an Unicode character, and returns it.stream:iterateBytes(): functionReturns an iterator function that returns a byte (number) when called. When the stream ends, it will automatically get closed.stream:iterateUnicodeChars(): functionReturns an iterator function that returns an Unicode character (string) when called. When the stream ends, it will automatically get closed.stream:close()Closes the file stream.
filesystem.makeReadStream(content: string): tableMakes a new readable file stream with the specified content and returns it. (seefilesystem.open())filesystem.remove(path: string): boolean or nil, stringRemoves the object atpath. Returnsniland an error message if an error occurred.filesystem.rename(path: string): boolean or nil, stringRenames the object at the specified path. Returnsniland an error message if an error occurred.filesystem.size(path: string): numberReturns the size of the file atpath. Returns 0 if the file does not exist or if it is a directory.
Last updated