- Documentation
- Files
Category
Files
All Lua functions and events in the Files category, on the server and the client.
Server functions 4
fileReturns a hash of the file content in hexadecimal. Useful to check whether a file has changed. The hash is computed from the content as UTF-8 text, so for binary files it may differ from hashes made by other tools. Algorithms:Get Hash "md5","sha1","sha224","sha256","sha384","sha512".pathChecks whether a path in the resource folder points to a folder.Is Directory pathChecks whether a path in the resource folder points to a file.Is File pathReturns a list of names in a resource folder; folder names end withList Dir /.
Shared functions 16
fileCloses a file and writes its buffer to disk. The handle becomes invalid.Close fileCopies a file to a new path. An existing target file is overwritten only withCopy overwrite = true.fileCreates a new file or empties an existing one and opens it for writing. On the client the files go to a private folder for that server on the player's computer (limit 64 MB per file and 256 MB per server).Create fileDeletes a file. The file must not be open at the time.Delete fileChecks whether a file with this path exists.Exists fileWrites buffered file data to disk without closing it. Useful for logs that must survive a crash.Flush fileReads a whole file in one call. Accepts a file handle or a path (it then opens and closes the file itself).Get Contents fileReturns the path of an open file (as given when opening it).Get Path fileReturns the current position in the file (bytes from the start).Get Pos fileReturns the file size in bytes.Get Size fileChecks whether the file position has reached the end.Is EOF fileOpens an existing file for reading and writing (or read-only). On the server the path is relative to the resource folder and cannot leave it. On the client it first looks for the script's own files (written withOpen fileCreate), then for<file>files sent by the server - those are read-only;":other/file"points to another resource's file. Close the file withfileClosewhen done.fileReads the given number of bytes from the current position and moves the position. At the end of the file it returns an empty string. Binary data is returned unchanged.Read fileRenames a file or moves it within the resource folder.Rename fileSets the file position for the next read or write (e.g.Set Pos fileGetSize= append at the end).fileWrites strings from the current position (each argument one after another) and moves the position. Supports binary data.Write