fs
Info
Paths, by default, are relative to csgo.exe
file. Consider that when operating with filesystem.
Note
Most of the functions here require SCRIPTS > General > Allow insecure to be enabled.
read
fs.read(path: string)
-> string
Reads a file from disc.
Parameters
Name | Type | Description |
---|---|---|
path |
string | File path |
Usage
local file_content = fs.read('some_file.txt');
read_stream
fs.read_stream(path: string)
-> table[char]
Reads a file from disc as a table of chars.
Parameters
Name | Type | Description |
---|---|---|
path |
string | File path |
Usage
local file_content = fs.read_stream('some_file.txt');
write
fs.write(path: string, data: string)
Writes data to a file.
Parameters
Name | Type | Description |
---|---|---|
path |
string | File path |
data |
string | Data to write |
Usage
fs.write('some_file.txt', 'Hello World');
write_stream
fs.write_stream(path: string, data: table[char])
Writes data to a file. Takes a table of chars instead of a string for the data parameter.
Parameters
Name | Type | Description |
---|---|---|
path |
string | File path |
data |
table[char] | Chars array. (Note: a valid character is a number between 0 and 255 .) |
Usage
fs.write('some_file.txt', {'H', 'e', 'l', 'l', 'o'});
remove
fs.remove(path: string)
Removes a file from disc.
Parameters
Name | Type | Description |
---|---|---|
path |
string | File path |
Usage
fs.remove('some_file.txt');
exists
fs.exists(path: string)
-> bool
Checks if a file exists on disc.
Parameters
Name | Type | Description |
---|---|---|
path |
string | File path |
Usage
if fs.exists('some_file.txt') then
-- ...
end
is_file
fs.is_file(path: string)
-> bool
Checks if a path is a file.
Parameters
Name | Type | Description |
---|---|---|
path |
string | Target path |
Usage
if fs.is_file('some_file.txt') then
-- ...
end
is_dir
fs.is_dir(path: string)
-> bool
Checks if a path is a directory.
Parameters
Name | Type | Description |
---|---|---|
path |
string | Target path |
Usage
if fs.is_dir('some_dir') then
-- ...
end
create_dir
fs.create_dir(path: string)
Creates a directory.
Info
You may specify as much directories as you want in a single call - all of them would be created recursively. If a directory already exists, no error will occur.
Parameters
Name | Type | Description |
---|---|---|
path |
string | Target path |
Usage
fs.create_dir('path/to/dir');