有谁知道如何在 erlang 中解压受密码保护的文件

发布于 2024-12-22 00:07:14 字数 254 浏览 5 评论 0原文

有 3 个问题

  1. 如何在 erlang 中解压缩或打开受密码保护的 zip 文件?
  2. 解压 zip 文件后,按扩展名对所有文件进行排序,例如 filelib:wildcard("*.?erl")?
  3. 将所有排序的文件放在不同的文件中,即 file:write(all *.erl -> to erlfile) 和 file:write(all *.beam -> to beamfile)

谢谢

Have 3 questions

  1. how to unzip or open a password protected zip file in erlang?
  2. after unziping the zip file, sorting all files by extention some thing like filelib:wildcard("*.?erl")?
  3. put all sorted files i different files i.e file:write(all *.erl -> to erlfile) and file:write(all *.beam -> to beamfile)

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

智商已欠费 2024-12-29 00:07:14

至于1.,我认为你不容易做到这一点。您必须调用一些外部脚本并通过端口观察其行为。

对于2,您可以执行以下操作:

 Filenames = ["foo.erl", "bar.txt", "baz.erl"],
 Sorted = lists:keysort(1, [{filename:extension(Name), Name} || Name <- Filenames])
 [Name || {_, Name} <- Sorted].

对于3,如果空间没有问题,则将它们全部读入内存,将数据收集到iolist()中并将该数据写回所需的输出文件。如果空间是个问题,您需要稍微流式传输数据并分块读取。

As for 1., I don't think you can do that easily. You have to call some external script and observe its behaviour through a port.

As for 2, you can do the following:

 Filenames = ["foo.erl", "bar.txt", "baz.erl"],
 Sorted = lists:keysort(1, [{filename:extension(Name), Name} || Name <- Filenames])
 [Name || {_, Name} <- Sorted].

As for 3, if space is no problem, then read all of them into memory, gather the data in an iolist() and write that one back to the desired output file. If space is a problem you need to stream data a bit and read in chunks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文