Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracted and saved vpk with inconsistent tree_length #35

Open
invokerbyxv opened this issue Dec 8, 2024 · 0 comments
Open

Extracted and saved vpk with inconsistent tree_length #35

invokerbyxv opened this issue Dec 8, 2024 · 0 comments

Comments

@invokerbyxv
Copy link

I tried to do an extraction of the VPK file and repackaged it.

def extract():
    pak1 = vpk.open("E:/Program Files (x86)/Steam/steamapps/workshop/content/570/2967026351/2967026351.vpk")
    for filepath in pak1:
        print(filepath)
        file = pak1.get_file(filepath)
        path = os.path.join("./Lost_Temple", filepath)
        directory = os.path.dirname(path)
        if not os.path.exists(directory):
            os.makedirs(directory, exist_ok=True)
        file.save(path)

def pack_vpk():
    pak = vpk.new("./Lost_Temple")
    pak.save("E:/Program Files (x86)/Steam/steamapps/workshop/content/570/2967026351/2967026352.vpk")

But when I open 2967026352.vpk using GCFSpace, I get an error: Could not open 2967026352.vpk. Invalid file: The file map is not within mapping bounds.

Then I realized that the repackaged VPK tree_length didn't match the source file.

def print_vpk():
    pak1 = vpk.open("E:/Program Files (x86)/Steam/steamapps/workshop/content/570/2967026351/2967026351.vpk")
    # 242158
    print(pak1.tree_length)
    pak2 = vpk.open("E:/Program Files (x86)/Steam/steamapps/workshop/content/570/2967026351/2967026352.vpk")
    # 242114
    print(pak2.tree_length)

Did I do something wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant