There are several syntax errors here.
1) To call a function defined in a module, use Module:Function(Arguments)
.
zip:unzip(Zipfile). % not zip.unzip()
2) Tokens begin with a lowercase character is called atom
s, which are just some literals. You should use variables for the first argument of unzip/2
.
Zipfile = "/path/to/your/zipfile.zip".
zip:unzip(Zipfile).
3) For the second argument of unzip/2
, let's see how to understand the document you post:
unzip(Archive, Options) -> RetValue
This is the function signature: two variable arguments and a return value
Archive = file:name() | binary()
The first argument should be of type file:name()
or binary
Options = [Option]
Options
argument should be a list.
Option = {file_list, FileList} |
keep_old_files |
verbose |
memory |
{file_filter, FileFilter} |
{cwd, CWD}
There are several forms of the list, including the one you need: {cwd, CWD}
, which is a tuple, whose first element is atom cwd
.
We have all the knowledge to call zip:unzip/2
correctly now:
Zipfile = "/path/to/your/zipfile.zip".
MyCwd = "/path/to/working_dir/".
zip:unzip(ZipPath, [{cwd, MyCwd}]).