Files (function list)
Status: Implemented (API 1.24). Generated from
client/clight/idl/clight_api.jsonbytools/docs/gen_api_reference.py; do not edit by hand. 13 functions, the newest from API 1.20.
Explanations and examples: Filesystem and HTTP. Every function of the fs module is listed here in table order.
The details of each function follow the table, in the same order. Side: where the function works (server, client, both). Context: the thread it may be called on (Conventions). Since: the API version that added it.
| C function | Lua | Side | Context | Since |
|---|---|---|---|---|
cl_fs_read |
cl.fs.read |
both | ANY | 1.20 |
cl_fs_read_text |
cl.fs.read_text |
both | ANY | 1.20 |
cl_fs_write |
cl.fs.write |
both | ANY | 1.20 |
cl_fs_write_text |
cl.fs.write_text |
both | ANY | 1.20 |
cl_fs_append_text |
cl.fs.append_text |
both | ANY | 1.20 |
cl_fs_exists |
cl.fs.exists |
both | ANY | 1.20 |
cl_fs_stat |
cl.fs.stat |
both | ANY | 1.20 |
cl_fs_list |
cl.fs.list |
both | ANY | 1.20 |
cl_fs_mkdir |
cl.fs.mkdir |
both | ANY | 1.20 |
cl_fs_remove |
cl.fs.remove |
both | ANY | 1.20 |
cl_fs_rename |
cl.fs.rename |
both | ANY | 1.20 |
cl_fs_data_used |
cl.fs.data_used |
both | ANY | 1.20 |
cl_fs_data_quota |
cl.fs.data_quota |
both | ANY | 1.20 |
cl_fs_read
cl_buf cl_fs_read(cl_str path);
The whole file (owned buf; null + cl_last_error on failure).
- Side: both. Context: ANY (any thread). Since: API 1.20.
- Lua:
cl.fs.read - C++:
clight::fs::read(std::string_view path)→Buf - The returned handle is owned: release it ©, or let the RAII class do it (C++). Lua releases it when it is collected (or at once with
local s <close> = ...).
cl_fs_read_text
cl_result cl_fs_read_text(cl_str path, char* buf, size_t cap, size_t* out_len);
The whole file as text (two-call string).
- Side: both. Context: ANY (any thread). Since: API 1.20.
- Lua:
cl.fs.read_text - C++:
clight::fs::read_text(std::string_view path)→Expected<std::string> - Writes a string:
buf/cap/out_len(a too small buffer returnsCL_E_BUFFER_TOO_SMALLwith the needed length in*out_len). Lua and C++ return the string. - Returns
CL_OKor an error code (Error codes). Lua raises acl.Erroron failure.
cl_fs_write
cl_result cl_fs_write(cl_str path, cl_buf data);
Replaces the file with the buf’s bytes (all of them, from the start); missing folders are created.
- Side: both. Context: ANY (any thread). Since: API 1.20.
- Lua:
cl.fs.write - C++:
clight::fs::write(std::string_view path, cl_buf data)→Expected<void> - Returns
CL_OKor an error code (Error codes). Lua raises acl.Erroron failure.
cl_fs_write_text
cl_result cl_fs_write_text(cl_str path, cl_str text);
- Side: both. Context: ANY (any thread). Since: API 1.20.
- Lua:
cl.fs.write_text - C++:
clight::fs::write_text(std::string_view path, std::string_view text)→Expected<void> - Returns
CL_OKor an error code (Error codes). Lua raises acl.Erroron failure.
cl_fs_append_text
cl_result cl_fs_append_text(cl_str path, cl_str text);
Adds the text at the end (creates the file).
- Side: both. Context: ANY (any thread). Since: API 1.20.
- Lua:
cl.fs.append_text - C++:
clight::fs::append_text(std::string_view path, std::string_view text)→Expected<void> - Returns
CL_OKor an error code (Error codes). Lua raises acl.Erroron failure.
cl_fs_exists
bool cl_fs_exists(cl_str path);
- Side: both. Context: ANY (any thread). Since: API 1.20.
- Lua:
cl.fs.exists - C++:
clight::fs::exists(std::string_view path)→bool
cl_fs_stat
cl_result cl_fs_stat(cl_str path, cl_fs_info* out);
CL_E_NOT_FOUND when nothing is there.
- Side: both. Context: ANY (any thread). Since: API 1.20.
- Lua:
cl.fs.stat - C++:
clight::fs::stat(std::string_view path)→Expected<cl_fs_info> - The last parameter receives the result. Lua returns it; C++ returns it in
Expected<T>. - Returns
CL_OKor an error code (Error codes). Lua raises acl.Erroron failure.
cl_fs_list
cl_result cl_fs_list(cl_str path, char* buf, size_t cap, size_t* out_len);
The entries of a folder, one name per line, sorted; folders end with “/”. At most 4096 entries (CL_E_LIMIT beyond).
- Side: both. Context: ANY (any thread). Since: API 1.20.
- Lua:
cl.fs.list - C++:
clight::fs::list(std::string_view path)→Expected<std::string> - Writes a string:
buf/cap/out_len(a too small buffer returnsCL_E_BUFFER_TOO_SMALLwith the needed length in*out_len). Lua and C++ return the string. - Returns
CL_OKor an error code (Error codes). Lua raises acl.Erroron failure.
cl_fs_mkdir
cl_result cl_fs_mkdir(cl_str path);
Creates the folder and its parents (data/ only).
- Side: both. Context: ANY (any thread). Since: API 1.20.
- Lua:
cl.fs.mkdir - C++:
clight::fs::mkdir(std::string_view path)→Expected<void> - Returns
CL_OKor an error code (Error codes). Lua raises acl.Erroron failure.
cl_fs_remove
cl_result cl_fs_remove(cl_str path, bool recursive);
Removes a file or an empty folder; recursive: a folder with everything in it. data/ itself can’t be removed.
- Side: both. Context: ANY (any thread). Since: API 1.20.
- Lua:
cl.fs.remove - C++:
clight::fs::remove(std::string_view path, bool recursive)→Expected<void> - Returns
CL_OKor an error code (Error codes). Lua raises acl.Erroron failure.
cl_fs_rename
cl_result cl_fs_rename(cl_str from, cl_str to);
Moves or renames inside data/ (replaces an existing file).
- Side: both. Context: ANY (any thread). Since: API 1.20.
- Lua:
cl.fs.rename - C++:
clight::fs::rename(std::string_view from, std::string_view to)→Expected<void> - Returns
CL_OKor an error code (Error codes). Lua raises acl.Erroron failure.
cl_fs_data_used
uint64_t cl_fs_data_used(void);
Bytes in the mod’s data folder now, and its limit.
- Side: both. Context: ANY (any thread). Since: API 1.20.
- Lua:
cl.fs.data_used - C++:
clight::fs::data_used()→uint64_t
cl_fs_data_quota
uint64_t cl_fs_data_quota(void);
- Side: both. Context: ANY (any thread). Since: API 1.20.
- Lua:
cl.fs.data_quota - C++:
clight::fs::data_quota()→uint64_t