Skip to content

Commit 8b81113

Browse files
committed
Fix: catch zlib errors
1 parent ea89d34 commit 8b81113

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/extract-zlib.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
module VBiosFinder
44
class Extract
55
def self.zlib file
6-
File.open file, "r:ASCII-8BIT" do |data|
7-
File.open "#{file}-zlib", "w:ASCII-8BIT" do |outdata|
8-
outdata.write Zlib::Inflate.inflate(data.read)
6+
target = "#{file}-zlib"
7+
begin
8+
File.open file, "r:ASCII-8BIT" do |data|
9+
File.open target, "w:ASCII-8BIT" do |outdata|
10+
outdata.write Zlib::Inflate.inflate(data.read)
11+
end
912
end
13+
rescue Zlib::DataError
14+
puts "wrong guess :(".colorize(:red)
15+
FileUtils.rm target
1016
end
1117
end
1218
end

0 commit comments

Comments
 (0)