--- zip_r11b5.erl 2008-01-01 14:44:19.000000000 +0100 +++ zip.erl 2008-04-02 12:43:30.000000000 +0200 @@ -236,7 +236,10 @@ {value, #zip_file{offset = Offset}} -> In1 = Input({seek, bof, Offset}, In0), {R, _In2} = get_z_file(In1, Z, Input, Output, [], fun silent/1, CWD), - {ok, R}; + case get_z_file(In1, Z, Input, Output, [], fun silent/1, CWD) of + {file, R, _In2} -> {ok, R}; + {dir, _In2} -> throw(file_not_found) + end; _ -> throw(file_not_found) end; do_openzip_get(_, _) -> @@ -1057,8 +1060,8 @@ In1 = Input({seek, bof, Offset}, In0), {In2, Acc1} = case get_z_file(In1, Z, Input, Output, OpO, FB, CWD) of - {GZD, Inx} -> {Inx, [GZD | Acc0]}; - Inx -> {Inx, Acc0} + {file, GZD, Inx} -> {Inx, [GZD | Acc0]}; + {dir, Inx} -> {Inx, Acc0} end, get_z_files(Rest, Z, In2, Opts, Acc1); _ -> @@ -1086,8 +1089,8 @@ case lists:last(FileName) of $/ -> %% perhaps this should always be done? - filelib:ensure_dir(FileName1), - In3; + Output({ensure_dir, FileName1}, []), + {dir, In3}; _ -> %% FileInfo = local_file_header_to_file_info(LH) %%{Out, In4, CRC, UncompSize} = @@ -1099,7 +1102,7 @@ %% In5 = Input({set_file_info, FileName, FileInfo#file_info{size=UncompSize}}, In4), FB(FileName), CRC =:= CRC32 orelse throw({bad_crc, FileName}), - {Out, In5} + {file, Out, In5} end; _ -> throw(bad_local_file_header) @@ -1397,6 +1400,8 @@ binary_io({close, FN}, {_Pos, B}) -> {FN, B}; binary_io({set_file_info, _F, _FI}, B) -> + B; +binary_io({ensure_dir, _F}, B) -> B. file_io({file_info, F}, _) -> @@ -1451,4 +1456,7 @@ case file:write_file_info(F, FI) of ok -> H; {error, Error} -> throw(Error) - end. + end; +file_io({ensure_dir, F}, H) -> + filelib:ensure_dir(F), + H.