From a20eb61c2fdd027a89acd249eea4f452e4accfb8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?H=C3=A5kan=20Mattsson?= By convention, the name of a zip file should end in " Zip archives are created with the
- Zip archives are created with the
+ To extract files from a zip archive, use the
- To extract files from a zip archive, use the
+ To return a list of the files in a zip archive, use the
+ To fold a function over all files in a zip archive, use the
+ To return a list of the files in a zip archive, use the
means that all files will be compressed (as long
- as they pass the
means that only files with exactly these extensions - will be compressed.
adds these extensions to the list of compress - extensions.
deletes these extensions from the list of compress - extensions.
means that no files will be compressed.
means that no files will be compressed.
means that files with these extensions will be - uncompressed.
adds these extensions to the list of uncompress - extensions.
deletes these extensions from the list of uncompress - extensions.
The
For example:
++> Name = "dummy.zip". +"dummy.zip" +> {ok, {Name, Bin}} = zip:create(Name, [{"foo", <<"FOO">>}, {"bar", <<"BAR">>}], [memory]). +{ok,{"dummy.zip", + <<80,75,3,4,20,0,0,0,0,0,74,152,97,60,171,39,212,26,3,0, + 0,0,3,0,0,...>>}} +> {ok, FileSpec} = zip:foldl(fun(N, I, B, Acc) -> [{N, B(), I()} | Acc] end, [], {Name, Bin}). +{ok,[{"bar",<<"BAR">>, + {file_info,3,regular,read_write, + {{2010,3,1},{19,2,10}}, + {{2010,3,1},{19,2,10}}, + {{2010,3,1},{19,2,10}}, + 54,1,0,0,0,0,0}}, + {"foo",<<"FOO">>, + {file_info,3,regular,read_write, + {{2010,3,1},{19,2,10}}, + {{2010,3,1},{19,2,10}}, + {{2010,3,1},{19,2,10}}, + 54,1,0,0,0,0,0}}]} +> {ok, {Name, Bin}} = zip:create(Name, lists:reverse(FileSpec), [memory]). +{ok,{"dummy.zip", + <<80,75,3,4,20,0,0,0,0,0,74,152,97,60,171,39,212,26,3,0, + 0,0,3,0,0,...>>}} +> catch zip:foldl(fun("foo", _, B, _) -> throw(B()); (_, _, _, Acc) -> Acc end, [], {Name, Bin}). +<<"FOO">> ++