anchor.diff:  get_sync(_, _) -> full.
   
   %% compress data
  -put_z_data_loop(0, _In, Out, Pos, _Input, _Output, _Z) ->
  -    {Out, Pos};
  -put_z_data_loop(UncompSize, In0, Out0, Pos0, Input, Output, Z) ->
  +put_z_data_loop(0, _In, Out, Pos, _Input, _Output, CRC0, _Z) ->
  +    {Out, Pos, CRC0};
  +put_z_data_loop(UncompSize, In0, Out0, Pos0, Input, Output, CRC0, Z) ->
       N = erlang:min(?WRITE_BLOCK_SIZE, UncompSize),
       case Input({read, N}, In0) of
  -	{eof, _In1} ->
  -	    {Out0, Pos0};
  -	{Uncompressed, In1} ->
  -	    Compressed = zlib:deflate(Z, Uncompressed, get_sync(N, UncompSize)),
  -	    Sz = erlang:iolist_size(Compressed),
  -	    Out1 = Output({write, Compressed}, Out0),
  -	    put_z_data_loop(UncompSize - N, In1, Out1, Pos0 + Sz,
  -			      Input, Output, Z)
  +        {eof, _In1} ->
  +            {Out0, Pos0};
  +        {Uncompressed, In1} ->
  +            CRC1 = erlang:crc32(CRC0, Uncompressed),
  +            Compressed = zlib:deflate(Z, Uncompressed, get_sync(N, UncompSize)),
  +            Sz = erlang:iolist_size(Compressed),
  +            Out1 = Output({write, Compressed}, Out0),
  +            put_z_data_loop(UncompSize - N, In1, Out1, Pos0 + Sz,
  +                Input, Output, CRC1, Z)
       end.
   
   %% raw iterators over central dir
  
positive.code:     {Out, Pos + Sz, 0};
  put_z_file(_Method, 0, Out, _F, Pos, _Input, _Output, _OpO, _Z, regular) ->
      {Out, Pos, 0};
  put_z_file(?STORED, UncompSize, Out0, F, Pos0, Input, Output, OpO, Z, regular) ->
      In0 = [],
      In1 = Input({open, F, OpO -- [write]}, In0),
      CRC0 = zlib:crc32(Z, <<>>),
      {Data, In2} = Input({read, UncompSize}, In1),
      Out1 = Output({write, Data}, Out0),
      CRC = zlib:crc32(Z, CRC0, Data),
      Input(close, In2),
      {Out1, Pos0+erlang:iolist_size(Data), CRC};
  put_z_file(?DEFLATED, UncompSize, Out0, F, Pos0, Input, Output, OpO, Z, regular) ->
      In0 = [],
      In1 = Input({open, F, OpO -- [write]}, In0),
      ok = zlib:deflateInit(Z, default, deflated, -?MAX_WBITS, 8, default),
      {Out1, Pos1} =
  	put_z_data_loop(UncompSize, In1, Out0, Pos0, Input, Output, Z),
      CRC = zlib:crc32(Z),
      ok = zlib:deflateEnd(Z),
      Input(close, In1),
      {Out1, Pos1, CRC}.
  
negative.code: get_z_data(?DEFLATED, In0, FileName, CompSize, Input, Output, OpO, Z) ->
      ok = zlib:inflateInit(Z, -?MAX_WBITS),
      Out0 = Output({open, FileName, [write | OpO]}, []),
      CRC0 = 0,
      {In1, Out1, UncompSize, CRC} = get_z_data_loop(CompSize, 0, In0, Out0, Input, Output, CRC0, Z),
      ?CATCH zlib:inflateEnd(Z),
      Out2 = Output({close, FileName}, Out1),
      {Out2, In1, CRC, UncompSize};
  get_z_data(?STORED, In0, FileName, CompSize, Input, Output, OpO, _Z) ->
      Out0 = Output({open, FileName, [write | OpO]}, []),
      CRC0 = 0,
      {In1, Out1, CRC} = copy_data_loop(CompSize, In0, Out0, Input, Output, CRC0),
      Out2 = Output({close, FileName}, Out1),
      {Out2, In1, CRC, CompSize};
  get_z_data(_, _, _, _, _, _, _, _) ->
      throw(bad_file_header).
  
  copy_data_loop(0, In, Out, _Input, _Output, CRC) ->
      {In, Out, CRC};
  copy_data_loop(CompSize, In0, Out0, Input, Output, CRC0) ->
      N = erlang:min(?READ_BLOCK_SIZE, CompSize),
      case Input({read, N}, In0) of
          {eof, In1} ->
              {Out0, In1};
          {Uncompressed, In1} ->
              CRC1 = erlang:crc32(CRC0, Uncompressed),
              Out1 = Output({write, Uncompressed}, Out0),
              copy_data_loop(CompSize-N, In1, Out1, Input, Output, CRC1)
      end.
  
  get_z_data_loop(0, UncompSize, In, Out, _Input, _Output, CRC0, _Z) ->
      {In, Out, UncompSize, CRC0};
  get_z_data_loop(CompSize, UncompSize, In0, Out0, Input, Output, CRC0, Z) ->
      N = erlang:min(?READ_BLOCK_SIZE, CompSize),
      case Input({read, N}, In0) of
          {eof, In1} ->
              {Out0, In1};
          {Compressed, In1} ->
              Uncompressed = zlib:inflate(Z, Compressed),
              CRC1 = erlang:crc32(CRC0, Uncompressed),
              Out1 = Output({write, Uncompressed}, Out0),
              get_z_data_loop(CompSize-N, UncompSize + iolist_size(Uncompressed),
                  In1, Out1, Input, Output, CRC1, Z)
      end.
  
  
  