Skip to content

Commit

Permalink
Use constants for the compression level gp flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
hainesr committed Aug 7, 2020
1 parent dcd8e3f commit 8d9c42d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/zip/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ class Entry
# Language encoding flag (EFS) bit
EFS = 0b100000000000

# Compression level flags (used as part of the gp flags).
COMPRESSION_LEVEL_SUPERFAST_GPFLAG = 0b110
COMPRESSION_LEVEL_FAST_GPFLAG = 0b100
COMPRESSION_LEVEL_MAX_GPFLAG = 0b010

attr_accessor :comment, :compressed_size, :follow_symlinks, :name,
:restore_ownership, :restore_permissions, :restore_times,
:size, :unix_gid, :unix_perms, :unix_uid, :zipfile
Expand Down Expand Up @@ -720,11 +725,11 @@ def set_compression_level_flags

case @compression_level
when 1
@gp_flags |= 0b110
@gp_flags |= COMPRESSION_LEVEL_SUPERFAST_GPFLAG
when 2
@gp_flags |= 0b100
@gp_flags |= COMPRESSION_LEVEL_FAST_GPFLAG
when 8, 9
@gp_flags |= 0b010
@gp_flags |= COMPRESSION_LEVEL_MAX_GPFLAG
end
end

Expand Down

0 comments on commit 8d9c42d

Please sign in to comment.