欢迎来到蓝梦软件下载中心!
免责声明:本站软件仅用于恢复和销毁存储介质数据,如果涉及个人隐私等问题,请使用者自行承担,使用软件默认同意本声明!
Q Q:1731278955
传真:0510-82737376
手机:13400027332
E-mail:1731278955@qq.com

技术文章
您所在的位置:首页 > 技术文章 >

ZIP压缩文件数据结构解析十八



作者: 来源: 日期:2018/1/7 7:22:00 人气:3 

    otherwise if the follower set S(Last-Character) is non-empty then

        read 1 bit from the input stream.

        if this bit is not zero then

            read 8 bits from the input stream, and copy this

            value to the output stream.

        otherwise if this bit is zero then

            read B(N(Last-Character)) bits from the input

            stream, and assign this value to I.

            Copy the value of S(Last-Character)[I] to the

            output stream.

    assign the last value placed on the output stream to

    Last-Character.

end loop

B(N(j)) is defined as the minimal number of bits required to

encode the value N(j)-1.

The decompressed stream from above can then be expanded to

re-create the original file as follows:

let State <- 0.

loop until done

    read 8 bits from the input stream into C.

    case State of

        0:  if C is not equal to DLE (144 decimal) then

                copy C to the output stream.

            otherwise if C is equal to DLE then

                let State <- 1.

        1:  if C is non-zero then

                let V <- C.

                let Len <- L(V)

                let State <- F(Len).

            otherwise if C is zero then

                copy the value 144 (decimal) to the output stream.

                let State <- 0

        2:  let Len <- Len + C

            let State <- 3.

        3:  move backwards D(V,C) bytes in the output stream

            (if this position is before the start of the output

            stream, then assume that all the data before the

            start of the output stream is filled with zeros).

            copy Len+3 bytes from this position to the output stream.

            let State <- 0.

    end case

end loop

The functions F,L, and D are dependent on the 'compression

factor', 1 through 4, and are defined as follows:

For compression factor 1:

    L(X) equals the lower 7 bits of X.

    F(X) equals 2 if X equals 127 otherwise F(X) equals 3.

    D(X,Y) equals the (upper 1 bit of X) * 256 + Y + 1.

For compression factor 2:

    L(X) equals the lower 6 bits of X.

    F(X) equals 2 if X equals 63 otherwise F(X) equals 3.

    D(X,Y) equals the (upper 2 bits of X) * 256 + Y + 1.

For compression factor 3:

    L(X) equals the lower 5 bits of X.

    F(X) equals 2 if X equals 31 otherwise F(X) equals 3.

    D(X,Y) equals the (upper 3 bits of X) * 256 + Y + 1.