Git Product home page Git Product logo

godotpcktool's Introduction

Godot Pck Tool

A standalone executable for unpacking and packing Godot .pck files.

Command line usage

For these you just need the GodotPckTool executable. Available from the releases page. Or see the end of this file for building instructions.

Note: if you don't install it on Linux you need to either use the full path or put it in a folder and run it as ./godotpcktool similarly to Windows.

You can view the tool help by running godotpcktool -h

Listing contents

Lists the files inside a pck file.

godotpcktool Thrive.pck

Long form:

godotpcktool --pack Thrive.pck --action list

Extracting contents

Extracts the contents of a pck file.

godotpcktool Thrive.pck -a e -o extracted

Long form:

godotpcktool --pack Thrive.pck --action extract --output extracted

Adding content

Adds content to an existing pck or creates a new pck. When creating a new pck you can specify which Godot version the pck file says it is packed with using the flag set-godot-version.

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

Long form:

godotpcktool --pack Thrive.pck --action add --remove-prefix extracted --file extracted

Filters

Filters can be used to only act on a subset of files in a pck file, or from the filesystem.

Min size

Specify the minimum size under which files are excluded:

godotpcktool --min-size-filter 1000

This will exclude files with size 999 bytes and below.

Max size

Specify the maximum size above which files are excluded:

godotpcktool --max-size-filter 1000

NOTE: if you use max size to compliment min size extraction, you should subtract one from the size, otherwise you'll operate on the same files twice.

However if you want to work on exactly some size files you can specify the same size twice:

godotpcktool --min-size-filter 1 --max-size-filter 1

Include by name

The option to include files can be given a list of regular expressions that select only files that match at least one of them to be processed. For example, you can list all files containing "po" in their names with:

godotpcktool --include-regex-filter po

Or if you want to require that to be the file extension (note that different shells require different escaping):

godotpcktool -i '\.po'

Multiple regular expressions can be separated by comma, or specified by giving the option multiple times:

godotpcktool -i '\.po,\.txt'
godotpcktool -i '\.po' -i '\.txt'

If no include filter is specified, all files pass through it. So not specifying an include filter means "process all files".

Note that filtering is case-sensitive.

Exclude by name

Files can also be excluded if they match a regular expression:

godotpcktool --exclude-regex-filter txt

If both include and exclude filters are specified, then first the include filter is applied, after that the exclude filter is used to filter out files that passed the first filter. For example to find files containing "po" but no "zh":

godotpcktool -i '\.po' -e 'zh'

Overriding filters

If you need more complex filtering you can specify regular expressions with --include-override-filter which makes any file matching any of those regular expression be included in the operation, even if another filter would cause the file to be excluded. For example you can use this to set file size limits and then override those for specific type:

godotpcktool --min-size-filter 1000 --include-override-filter '\.txt'

Advanced Options

Specifying Engine Version

When creating a .pck file it is possible to specify the Godot engine version the .pck says it is created with:

godotpcktool NewPack.pck -a a some_file.txt --set-godot-version 3.5.0

Note that this approach does not override the engine version number in existing .pck files. This currently only applies to new .pck files.

General info

In the long form multiple files may be included like this:

godotpcktool ... --file firstfile,secondfile

Make sure to use quoting if your files contain spaces, otherwise the files will be interpreted as other options.

In the short form the files can just be listed after the other commands. If your file begins with a - you can prevent it from being interpreted as a parameter by adding -- between the parameters and the list of files.

Building

These are instructions for building this on Fedora, including cross compiling to Windows.

Note that native Linux build uses the glibc of the currently installed system, which may be too new for older distros. For a build that supports those, see the section about podman builds.

Required libraries

sudo dnf install cmake gcc-c++ libstdc++-static mingw32-gcc-c++ mingw32-winpthreads-static

Also don't forget to init git submodules.

git submodule init
git submodule update

Then just:

make

Also if you want to make a folder with the executables and cross compile:

make all-install

Podman build

Podman can be used to build a Linux binary using the oldest supported Ubuntu LTS. This ensures widest compatibility of the resulting binary.

First make sure podman and make are installed, then run the make target:

make compile-podman

Due to the use of C++ 17 and non-ancient cmake version, the oldest working Ubuntu LTS is currently 20.04.

godotpcktool's People

Contributors

calinou avatar dependabot[bot] avatar hhyyrylainen avatar nikitalita avatar rgson avatar songofabumblebee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

godotpcktool's Issues

TOC padding is wrong

The table of content padding calculation is wrong

In the file
PckFile.cpp
the lines 137--139

        const size_t pathToWriteSize =
            entry.Path.size() + (entry.Path.size() % PadPathsToMultipleWithNULLS);
        const size_t padding = pathToWriteSize - entry.Path.size();

The middle line should be
entry.Path.size() + (PadPathsToMultipleWithNULLS - entry.Path.size() % PadPathsToMultipleWithNULLS)

For reference, see the function
static int _get_pad(int p_alignment, int p_n)
in
editor_export_platform.cpp

Embedded pck files

Hi, first of all thanks for this great tool!

Is it possible to access the pck file if it is embedded in to the .exe?

I'm co creating a mod loader and as ithinkandicode mentioned in #25 we are using it with great success to add the mod loader autoload at the right spot to the project.binary.

Now we have the issue that some games embed the pck and it looks like we cant access that with the PckTool.

How to repack on Windows?

First of all, I'm not good at English.
Please forgive me because I am using machine translation.

Isn't Repack meant to turn unpacked files (in folders) into ".pck files" again?
Please tell me how to repack the folder containing the unpacked files into the ".pck file" again.

When I tried "godotpcktool.exe -p sample.pck -a r -f new.pck", "sample.pck" and "new.pck" did not become the same file.

I am very sorry for the basic question, but I would be very happy if you could reply.

Unicode support

It seems that for now unicode file names is not supported since after unpacking .pck I got few files that can't be packed back properly, For example: original file name "魔王魂 アコースティック25.ogg-0683c3a09e15adb36630a670de69ac05.oggstr" (got it with Godot RE Tools), GodotPckTool generated file name "魔王魂 アコースティック25.ogg-0683c3a09e15adb36630a670de69ac05.oggstr" so at importing back I got such error:

terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error'
  what():  filesystem error: cannot get file size: No such file or directory [extracted\.import\├Р┬У├В┬й├Р┬Т├В┬н├Р┬Т├в┬А┬Э├Р┬У├В┬з├Р┬Т├Р┬Л├Р┬Т├в┬А┬╣├Р┬У├В┬й├Р┬Т├В┬н├Р┬Т├в┬А┬Ъ ├Р┬У├Р┬И├Р┬Т├в┬А┬Ъ├Р┬Т├С┬Ю├Р┬У├Р┬И├Р┬Т├в┬А┬Ъ├Р┬Т├С┬Ц├Р┬У├Р┬И├Р┬Т├С┬У├Р┬Т├С┬Ш├Р┬У├Р┬И├Р┬Т├в┬А┬Ъ├Р┬Т├в┬Д┬Ц├Р┬У├Р┬И├Р┬Т├С┬У├Р┬Т├в┬А┬а├Р┬У├Р┬И├Р┬Т├в┬А┬Ъ├Р┬Т├Р┬И├Р┬У├Р┬И├Р┬Т├С┬У├Р┬Т├С┬У├Р┬У├Р┬И├Р┬Т├в┬А┬Ъ├Р┬Т├Р┬З06.ogg-bcfff188be40b560c38e232ce419ff3c.oggstr]

Add podman build workflow for working with older glibc

I am using Ubuntu 20.04.3 LTS.

Steps to reproduce

  • Download the godotpcktool binary for Linux
  • chmod +x
  • ./godotpcktool -h
  • The following error messages appear:

./godotpcktool: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by ./godotpcktool)
./godotpcktool: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./godotpcktool)

This only happens with the release binaries of 1.5 and 1.6.
The 1.4 binaries work as expected.

Support PCK format version 0 (Godot 2.x)

There were no changes to the PCK format between versions 0 (Godot 2.x) and 1 (3.x); they just changed the version number to make Godot 3.x refuse to load 2.x pcks and vice-versa.

Question: Absolute path problems

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

Add support for Godot 4 PCK files

I tried to use this tool to extract a PCK file from a Godot 4 project on Linux, and I got an error that the version is unsupported:

$ ../install/bin/godotpcktool mirror-client.pck 
ERROR: pck is unsupported version: 2
ERROR: couldn't load pck file: mirror-client.pck

Please add support for extracting PCK files from Godot 4.

Possible to overwrite files in the PCK?

Is it possible to overwrite files if they already exist in the PCK?

It seems like the only option atm is to unpack to a new folder, add the edited file, then make a new pack from that folder's contents. So I was hoping there might be a way to skip the unpack-repack part of the process.

The use case is for adding a mod loader as an autoload, before any other autoloads, so if possible I'd like to streamline the install process for users, and without exposing the game's assets.

Code analysis warning about string::find usage

GodotPckTool-master/src/pck/PckFile.cpp:293] (performance) Either inefficient or wrong usage of string::find(). string::starts_with() will be faster if string::find's result is compared with 0, because it will not scan the whole string. If your intention is to check that there are no findings in the string, you should compare with std::string::npos. [stlIfStrFind]

Add support for macOS

When I try to compile GodotPckTool using make on macOS, I get this output:

% make
cd build && cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/aaronfranke/workspace/GodotPckTool/build
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C build
Consolidate compiler generated dependencies of target pck
[ 16%] Building CXX object src/CMakeFiles/pck.dir/PckTool.cpp.o
[ 33%] Building CXX object src/CMakeFiles/pck.dir/FileFilter.cpp.o
[ 50%] Linking CXX static library libpck.a
[ 66%] Built target pck
[ 83%] Building CXX object src/CMakeFiles/godotpcktool.dir/main.cpp.o
[100%] Linking CXX executable godotpcktool
clang: error: invalid linker name in argument '-fuse-ld=gold'
clang: error: unsupported option '-static-libgcc'
make[3]: *** [src/godotpcktool] Error 1
make[2]: *** [src/CMakeFiles/godotpcktool.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [compile] Error 2

I'm not familiar with CMake, so I'm not sure how to add support for macOS. But I would greatly appreciate it, it would be useful to have when trying to debug a Mac build of my Godot project.

doesnt work or build

trying to extract files gives this

...
terminate called after throwing an instance of 'std::runtime_error'
  what():  files for entry contents failed
Aborted (core dumped)

trying to build, regardless of where i put MD5/src/md5.h (./, build/, src/) spits out this

CMake Error at third_party/CMakeLists.txt:13 (add_library):
  Cannot find source file:

    MD5/src/md5.h

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
  .ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
  .f95 .f03 .hip .ispc


CMake Error at third_party/CMakeLists.txt:13 (add_library):
  No SOURCES given to target: md5

also, is there a spec for the .pck format? id honestly rather ahead and rip the assets with dd at this point

Override file

If I were to add Globals.gd to the pck, is there any way to make it override the already built in Globals.gd?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.