Skip to content

Commit

Permalink
handle empty zip file
Browse files Browse the repository at this point in the history
  • Loading branch information
adavies42 committed Oct 26, 2023
1 parent 3714b3b commit 04faa55
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions q/unzip/unzip.q
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,28 @@
ecd64:.finos.unzip.priv.pecd64 .finos.unzip.priv.bytes[y;ecl64`cof;12+.finos.unzip.priv.parseNum .finos.unzip.priv.bytes[y;4+ecl64`cof;8]]];
ecd];

/ check for empty zip
if[not count cd;
:$[
`list=x;
([name:0#`]size:0#0Ni;timestamp:0#0Np);
`unzip=x;
$[
-11h=type z;
[
.finos.log.error(string z),": file not found in archive";
'z;
];
11h=type z;
[
{.finos.log.error(string x),": file not found in archive"}each z;
'first z;
];
z~(::);
((0#`)!())];
'`domain];
];

/ start of central directory
scd:$[-1=ecd`cof;ecd64;ecd]`cof;

Expand Down

0 comments on commit 04faa55

Please sign in to comment.