大佬们帮我看一下这个游戏资源包怎么解开

游戏资产文件应该在resource.awb这个自定义资源包里面,我丢给ai写python脚本解不出来,应该是识别不出resource.awb里面的文件路径和文件名称。
这个就是我让ChatGPT写的python脚本:
import os
import struct
import re

def safe_makedirs(path):
if path and not os.path.exists(path):
os.makedirs(path)

def read_string(f, length):
return f.read(length).decode(‘utf-8’, errors=‘ignore’)

def sanitize_path(path):
# 替换 Windows 不支持的路径字符
return re.sub(r’[<>:"/\|?*]', ‘_’, path)

def unpack_custom_awb(awb_path, output_dir, max_files=10000):
with open(awb_path, ‘rb’) as f:
file_size = os.path.getsize(awb_path)
count = 0

    while f.tell() < file_size and count < max_files:
        try:
            offset_bytes = f.read(4)
            if len(offset_bytes) < 4:
                break
            offset = struct.unpack('<I', offset_bytes)[0]

            size_bytes = f.read(4)
            if len(size_bytes) < 4:
                break
            size = struct.unpack('<I', size_bytes)[0]

            # 取消读取文件名长度和文件名,改用数字文件名
            # name_len_bytes = f.read(1)
            # if not name_len_bytes:
            #     break
            # name_len = struct.unpack('<B', name_len_bytes)[0]
            # raw_name = read_string(f, name_len)

            raw_name = f"file_{count}.bin"  # 临时用计数文件名

            print(f"Entry {count}: offset={offset}, size={size}, raw_name='{raw_name}'")

            if size == 0 or offset == 0:
                print(f"[!] 文件数据异常,跳过 Entry {count}")
                break

            clean_name = sanitize_path(raw_name)
            save_path = os.path.join(output_dir, clean_name)

            cur = f.tell()
            f.seek(offset, 0)
            content = f.read(size)
            f.seek(cur, 0)

            safe_makedirs(os.path.dirname(save_path))

            with open(save_path, 'wb') as out:
                out.write(content)

            print(f"[√] 解包: {raw_name} ({size} bytes)")
            count += 1

        except Exception as e:
            print(f"[!] 错误读取第 {count} 个文件: {e}")
            break

    print(f"\n[√] 解包完成,共提取 {count} 个文件 -> {output_dir}")

--------------------------

主程序入口

--------------------------

if name == ‘main’:
script_dir = os.path.dirname(os.path.abspath(file))
awb_file = os.path.join(script_dir, ‘resource.awb’)
output_folder = os.path.join(script_dir, ‘extracted’)

print(f"脚本目录: {script_dir}")
print(f"AWB 文件路径: {awb_file}")
print(f"AWB 文件是否存在: {os.path.isfile(awb_file)}")

safe_makedirs(output_folder)

if not os.path.isfile(awb_file):
    print(f"[!] 未找到 resource.awb")
else:
    unpack_custom_awb(awb_file, output_folder)