BF2 İçindeki Md5 Dosyası (Örnek)
-
Pythonla uğraşanlar için örnek olsun diye yazıyorum gereksiz görünürse silinebilir.
#! /usr/bin/python # # Generates striped MD5 fingerprints for BF2 content checking. # # Author: Andreas Fredriksson # Copyright (c)2005 Digital Illusions CE AB import os import os.path import md5 from optparse import OptionParser num_ordinals = 10 block_size = 16384 def ordinal_pass(files): ctx = [] for x in xrange(0, num_ordinals): ctx.append(md5.new()) for file in files: sz = os.stat(file).st_size num_blocks = (sz / block_size) + 1 inf = open(file, 'rb') for b_i in xrange(0, num_blocks+1, num_ordinals): for ordinal in xrange(0, num_ordinals): data = inf.read(block_size) if len(data) > 0: ctx[ordinal].update(data) #Take size into account as well. for ordinal in xrange(0, num_ordinals): ctx[ordinal].update(str(sz)) return ctx def run_fingerprint(files): ctx = ordinal_pass(files) tmp = [] for o in xrange(0, num_ordinals): tmp.append('%d %s' % (o, ctx[o].hexdigest())) return tmp def visitor(arcs, dirname, names): for fn_ in names: fn = fn_.lower() if fn == 'server.zip' or fn == 'client.zip': p = os.path.split(dirname)[1].lower() list = arcs.get(p, []) list.append(os.path.join(dirname, fn)) arcs[p] = list return names parser = OptionParser() parser.add_option( "--levels", action="store_true", dest="levels", default=False, help="Just checksum levels only") (options, args) = parser.parse_args() try: mod_name = args[0] except: print("\n****** Content Checking: Mod name missing - using mods/bf2 ******\n") mod_name = "bf2" mod_path = 'mods' + os.sep + mod_name files = [] files += [mod_path + os.sep + 'ClientArchives.con'] files += [mod_path + os.sep + 'ServerArchives.con'] std_archives = [] nite_archives = [] boost_archives = [] boost_nite_archives = [] if options.levels == False: print("\n****** Content Checking: Collecting " + mod_name + " common files to fingerprint... ******\n") for filename in files : of = open(filename,'r') for line in of : list = line.split(' ') if len(list) > 1 : archive = list[1] archive = archive.replace('\\',os.sep) archive = archive.replace('/',os.sep) if archive[:4] != 'mods' : archive = mod_path + os.sep + archive archive = archive.lower() if archive.find( 'shaders' ) >= 0: print("\nContent Checking: Found SHADER updating bf2 archives list...\n") bf2archive = "mods\\bf2\\shaders_client.zip" std_archives += [bf2archive] # Use bf2 shaders as day shaders nite_archives += [archive] # Use mods shaders as nite shaders boost_archives += [bf2archive] boost_nite_archives += [archive] else: if archive.find( 'booster' ) >= 0: print("\nContent Checking: Found BOOSTER ignoring for standard & nite archives list...\n") boost_archives += [archive] # only add to boster lists boost_nite_archives += [archive] else: std_archives += [archive] nite_archives += [archive] boost_archives += [archive] boost_nite_archives += [archive] of.close() std_archives.sort() nite_archives.sort() boost_archives.sort() boost_nite_archives.sort() print("Day Archives") for archive in std_archives : print archive print("Night Archives") for narchive in nite_archives : print narchive print("Booster Archives") for barchive in boost_archives : print barchive print("Booster+Night Archives") for bnarchive in boost_nite_archives : print bnarchive print("\n****** Content Checking: Processing " + mod_name + " common archives for DAY... ******\n") of = open(mod_path + os.sep + 'std_archive.md5', 'w') std_fps = run_fingerprint(std_archives) for s in std_fps: of.write(s) of.write('\n') of.close() print("\n****** Content Checking: Processing " + mod_name + " common archives for NIGHT... ******\n") of = open(mod_path + os.sep + 'std_archive_mod.md5', 'w') nite_fps = run_fingerprint(nite_archives) for s in nite_fps: of.write(s) of.write('\n') of.close() print("\n****** Content Checking: Processing " + mod_name + " common archives for BOOSTER... ******\n") of = open(mod_path + os.sep + 'bst_archive.md5', 'w') std_fps = run_fingerprint(boost_archives) for s in std_fps: of.write(s) of.write('\n') of.close() print("\n****** Content Checking: Processing " + mod_name + " common archives for BOOSTER+NIGHT... ******\n") of = open(mod_path + os.sep + 'bst_archive_mod.md5', 'w') std_fps = run_fingerprint(boost_nite_archives) for s in std_fps: of.write(s) of.write('\n') of.close() print("\n****** Content Checking: Collecting " + mod_name + " files to fingerprint... ******\n") lvl_archives = {} os.path.walk(mod_path + os.sep + 'levels', visitor, lvl_archives) print("\n****** Content Checking: Found " + str(len(lvl_archives)) + " " + mod_name + " Levels ******\n") print("\n****** Content Checking: Processing " + mod_name + " Level archives... ******\n") for level, arcs in lvl_archives.iteritems(): arcs.sort() fps = run_fingerprint(arcs) of = open(mod_path + os.sep + 'levels' + os.sep + level + os.sep + 'archive.md5', 'w') for fpr in fps: of.write('%s %s\n' % (level, fpr)) of.close(); print("\n****** Content Checking: " + mod_name + " Done ******\n")
Toplam Hit: 1000 Toplam Mesaj: 1
