zip
Note
Some of the functions here require SCRIPTS > General > Allow insecure to be enabled.
read
read(path: string)
-> string
Reads a file.
Parameters
Name | Type | Description |
---|---|---|
path |
string | File path |
Usage
local file_content = arc:read('some_file.txt');
read_stream
read_stream(path: string)
-> table[char]
Reads a file as a table of chars.
Parameters
Name | Type | Description |
---|---|---|
path |
string | File path |
Usage
local file_content = arc:read_stream('some_file.txt');
write
write(path: string, data: string)
Writes data to a file.
Parameters
Name | Type | Description |
---|---|---|
path |
string | File path |
data |
string | Data to write |
Usage
arc:write('some_file.txt', 'Hello World');
write_stream
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
arc:write('some_file.txt', {'H', 'e', 'l', 'l', 'o'});
save
save(path: string)
Saves an archive into a file.
Parameters
Name | Type | Description |
---|---|---|
path |
string | File path |
Usage
arc:save('my_arc.zip');
get_files
get_files()
-> table[{...}]
Returns all files in the archive.
Table parameters
Name | Type | Description |
---|---|---|
filename |
string | File name |
date_time.year |
number | Year |
date_time.month |
number | Month |
date_time.day |
number | Day |
date_time.hours |
number | Hours |
date_time.minutes |
number | Minutes |
date_time.seconds |
number | Seconds |
comment |
string | File comment |
compress_size |
number | Compressed size, in bytes |
file_size |
number | Uncompressed size, in bytes |
Usage
for k, v in ipairs(arc:get_files()) do
print(v.filename);
end
exists
exists(path: string)
-> bool
Checks if a file exists.
Parameters
Name | Type | Description |
---|---|---|
path |
string | File path |
Usage
if arc:exists('some_file.txt') then
-- ...
end
extract
extract(path: string, dest: string)
Extracts a file or a directory into destination.
Parameters
Name | Type | Description |
---|---|---|
path |
string | File or directory path |
dest |
string | Destination path |
Usage
arc:extract('my_file.txt', 'out/my_file.txt');
extract_all
extract_all(dest: string)
Extracts all files into a directory.
Parameters
Name | Type | Description |
---|---|---|
dest |
string | Destination directory |
Usage
arc:extract_all('out');