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 88require "./src/extract-7z"
99require "./src/extract-polyglot"
1010require "./src/extract-zlib"
11-
11+ require 'digest/md5'
12+ hash = { }
1213module VBiosFinder
1314 class Main
1415 @extractions = [ ]
@@ -65,6 +66,7 @@ def self.run file
6566 unless romdata . nil? || romdata [ 'vendor' ] . nil? || romdata [ 'device' ] . nil?
6667 puts "Found VBIOS for device #{ romdata [ 'vendor' ] } :#{ romdata [ 'device' ] } !" . colorize ( :green )
6768 new_filename = "vbios_#{ romdata [ 'vendor' ] } _#{ romdata [ 'device' ] } .rom"
69+ new_filename = check_cpy ( new_filename , romdata )
6870 FileUtils . cp ( mod , "#{ outpath } /#{ new_filename } " )
6971 end
7072 rescue Terrapin ::ExitStatusError => e
@@ -88,3 +90,21 @@ def self.run file
8890 end
8991 end
9092end
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