File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 8
8
require "./src/extract-7z"
9
9
require "./src/extract-polyglot"
10
10
require "./src/extract-zlib"
11
-
11
+ require 'digest/md5'
12
+ hash = { }
12
13
module VBiosFinder
13
14
class Main
14
15
@extractions = [ ]
@@ -65,6 +66,7 @@ def self.run file
65
66
unless romdata . nil? || romdata [ 'vendor' ] . nil? || romdata [ 'device' ] . nil?
66
67
puts "Found VBIOS for device #{ romdata [ 'vendor' ] } :#{ romdata [ 'device' ] } !" . colorize ( :green )
67
68
new_filename = "vbios_#{ romdata [ 'vendor' ] } _#{ romdata [ 'device' ] } .rom"
69
+ new_filename = check_cpy ( new_filename , romdata )
68
70
FileUtils . cp ( mod , "#{ outpath } /#{ new_filename } " )
69
71
end
70
72
rescue Terrapin ::ExitStatusError => e
@@ -88,3 +90,21 @@ def self.run file
88
90
end
89
91
end
90
92
end
93
+
94
+
95
+
96
+ def check_cpy ( new_filename , romdata )
97
+ count = 0
98
+ Dir . glob ( '**/*' , File ::FNM_DOTMATCH ) . each do |f |
99
+ key = Digest ::MD5 . hexdigest ( IO . read ( f ) ) . to_sym
100
+ if hash . has_key? ( key ) then hash [ key ] . push ( f ) else hash [ key ] = [ f ] end
101
+ end
102
+
103
+ hash . each_value do |a |
104
+ next if a . length == 1
105
+ count += 1
106
+ new_filename = "vbios_#{ romdata [ 'vendor' ] } _#{ romdata [ 'device' ] } _#{ count } .rom"
107
+
108
+ return new_filename
109
+ end
110
+ end
You can’t perform that action at this time.
0 commit comments