From a2d0b79c2efea6916ea497239a6aaab296b2284c Mon Sep 17 00:00:00 2001 From: CPunch Date: Tue, 5 Sep 2023 14:41:59 -0500 Subject: [PATCH] documented the new os.open and file objects --- docs/stdlib.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/stdlib.md b/docs/stdlib.md index e349b35..3811616 100644 --- a/docs/stdlib.md +++ b/docs/stdlib.md @@ -59,7 +59,12 @@ Includes functions that interact with the operating system. | Name | Type | Behavior | Example | | ------------ | ------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------ | -| os.read | `(path)` -> `` or `` | Returns a file's contents or nil if it doesn't exist/an error occurred | `os.read("path")` -> `Hello, World!`| +| os.open | `(path)` -> `, ` | Opens a file at `path` and returns a file object. If the file does not exist, it will be created. | `os.open("test.txt")` -> `true, ` | | os.time | `()` -> `` | Returns the system time in Epoch format | `os.time()` -> `1.61691e+09` | | os.system | `(cmd)` -> `` | Runs a system command as if it were a terminal and returns the exit code | `os.system("mkdir test")` -> `0` | -> -> means 'returns' \ No newline at end of file +> -> means 'returns' + +File objects have the following methods: +| Name | Type | Behavior | Example | +| ------------ | ------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------ | +| file:read | `(amt or "a")` -> `` | Reads `amt` bytes from the file and returns them as a string. If `"a"` is passed, the entire file is read. | `file:read("a")` -> `"Hello world!"` | \ No newline at end of file