node/lib/metasm/metasm/exe_format/zip.rb
# encode the data, fixup related fields
encode the data, fixup related fields
encode the data fixup related fields
def encode_data(zip)
			data = file_data(zip)
			@compress_method = 'NONE' if data == ''
			@crc32 = Zlib.crc32(data)
			@uncompressed_sz = data.length
			case compress_method
			when 'NONE'
			when 'DEFLATE'
				data = zlib_deflate(data)
			when nil
				cdata = zlib_deflate(data)
				ratio = cdata.length * 100 / data.length
				if ratio < 90
					@compress_method = 'DEFLATE'
					data = cdata
				else
					@compress_method = 'NONE'
				end
			end
			@compressed_sz = data.length
			data
		end
def encode_data ( zip ) data = file_data ( zip ) @compress_method = 'NONE' if data == '' @crc32 = Zlib . crc32 ( data ) @uncompressed_sz = data . length case compress_method when 'NONE' when 'DEFLATE' data = zlib_deflate ( data ) when nil cdata = zlib_deflate ( data ) ratio = cdata . length * 100 / data . length if ratio < 90 @compress_method = 'DEFLATE' data = cdata else @compress_method = 'NONE' end end @compressed_sz = data . length data end
encode the data, fixup related fields
encode the data fixup related fields
# autodetect compression method # compress if we win more than 10% space
zip