File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -80,11 +80,12 @@ def save_to(fname)
80
80
f . close
81
81
end
82
82
83
-
84
- #
85
83
# Compress this archive and return the resulting zip file as a String.
86
84
#
87
- def pack
85
+ # @param spoof [Hash{String => String}] The entries whose name need to be spoofed in the Central
86
+ # Directory.
87
+ # @return [String] The resulting zip file
88
+ def pack ( spoof = { } )
88
89
ret = ''
89
90
90
91
# save the offests
@@ -104,7 +105,7 @@ def pack
104
105
idx = 0
105
106
@entries . each { |ent |
106
107
cfd = CentralDir . new ( ent , offsets [ idx ] )
107
- ret << cfd . pack
108
+ ret << cfd . pack ( spoof )
108
109
idx += 1
109
110
}
110
111
Original file line number Diff line number Diff line change @@ -115,8 +115,16 @@ def initialize(entry, offset)
115
115
@hdr_offset = offset
116
116
end
117
117
118
- def pack
118
+ # Creates the central directory information about the particular Zip Entry.
119
+ #
120
+ # @param spoof [Hash{String => String}] The entries whose name need to be spoofed in the Central
121
+ # Directory.
122
+ # @return [String] The resulting zip file
123
+ def pack ( spoof = { } )
119
124
path = @entry . relative_path
125
+ if spoof . key? ( path )
126
+ path = spoof [ path ]
127
+ end
120
128
121
129
ret = [ SIGNATURE , ZIP_VERSION ] . pack ( 'Vv' )
122
130
ret << [ ZIP_VERSION ] . pack ( 'v' )
You can’t perform that action at this time.
0 commit comments