Esempio n. 1
0
def extract_category(args, conf):
    dat_manager = DatManager(conf.get('game', 'path'))

    category = dat_manager.get_category(args.name)
    output_path = path.join(conf.get('output', 'path'), 'cat', args.name)

    for dir_hash in category.get_hash_table().keys():
        output_dir_path = path.join(output_path, '%0.8X' % dir_hash)

        if not path.exists(output_dir_path):
            makedirs(output_dir_path)

        for file_hash in category.get_dir_hash_table(dir_hash).keys():
            output_file_path = path.join(output_dir_path, '%0.8X' % file_hash)

            file_data = category.get_file(dir_hash, file_hash)

            with open(output_file_path, 'wb') as file_handle:
                file_handle.write(file_data.getvalue())