hhyyrylainen / GodotPckTool

Standalone tool for extracting and creating Godot .pck files
MIT License
408 stars 34 forks source link

Question: Absolute path problems #27

Closed mobilex1122 closed 1 year ago

mobilex1122 commented 1 year ago

when you export using:

pcktool.exe -p test.pck -a a C://somepath... it will not work as it should:

when extracting it will put all files to there absolute positions insted of relative example: pcktool.exe -p test.pck -a e -o extracted will do: C:/somepath.../file but it should do: /extracted/file

it would be great if this got fixed. (I'm using this tool to create simple game engine)

terminal output when listing .pck files:

Screenshot 2023-02-03 184332

hhyyrylainen commented 1 year ago

When creating a .pck file, you need to specify a prefix to be removed, otherwise you end up with that incorrect .pck file that contains absolute paths in it.

I'd say the extraction part is not the problem here, but how the .pck is created. I'm pretty sure it is possible to create .pck files with correctly specified resource paths inside the .pck (without the absolute path from the host computer).

mobilex1122 commented 1 year ago

Ou I thought that remove prefix would remove part of filename for example: prefix_file.gd to file.gd You should specify what remove prefix does. But thanks for correction. One more question: I need to put the prefix in "" or how do I specify if. I would like to see some example command.

Thanks

hhyyrylainen commented 1 year ago

The remove prefix command works only when adding content.

There's an example in the readme file:

godotpcktool Thrive.pck -a a extracted --remove-prefix extracted

So that example means that Thrive.pck will get all the files from the folder called "extracted" and each item to be added will have "extracted" removed from the beginning, meaning the files in the folder will be called res://file.txt etc when added. So the files in the "extracted" folder become the root of the .pck file hierarchy with subfolders working normally. The whole reason the prefix removal parameter exists is for the use case where you want to add all files from a folder that exists somewhere.

For your .pck creating when adding files if you specify the prefix removal to be the start of the absolute path, then that part should not be included in the .pck file resulting in a properly working file. Whether you require quotes depends on if the path has spaces in it (and your shell environment).

Sadly you can't specify multiple prefixes to be removed, so before creating the .pck file you need to create one folder with all the files and subfolders you want to exist, then use the add command with path to that folder and the prefix remove option also set to be the path to that folder.