这里有几个语法错误。
1) 要调用模块中定义的函数,请使用Module:Function(Arguments)。
zip:unzip(Zipfile). % not zip.unzip()
2) 以小写字符开头的标记称为atoms,这只是一些文字。 unzip/2 的第一个参数应该使用变量。
Zipfile = "/path/to/your/zipfile.zip".
zip:unzip(Zipfile).
3)对于unzip/2的第二个参数,我们来看看如何理解你发布的文档:
unzip(Archive, Options) -> RetValue
这是函数签名:两个变量参数和一个返回值
Archive = file:name() | binary()
第一个参数的类型应该是file:name() 或二进制
Options = [Option]
Options 参数应该是一个列表。
Option = {file_list, FileList} |
keep_old_files |
verbose |
memory |
{file_filter, FileFilter} |
{cwd, CWD}
列表有多种形式,包括你需要的:{cwd, CWD},它是一个元组,它的第一个元素是原子cwd。
我们现在掌握了正确调用zip:unzip/2的所有知识:
Zipfile = "/path/to/your/zipfile.zip".
MyCwd = "/path/to/working_dir/".
zip:unzip(ZipPath, [{cwd, MyCwd}]).