-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Add PCKReader class #81372
base: master
Are you sure you want to change the base?
Add PCKReader class #81372
Conversation
26ee22d
to
87a141b
Compare
On a side note, I also rewrote the embedded loading of pck files here: yvie-k@a5d5ec8 This would only try to load the embedded pck of the executable and not every opened pack file I didn't include it as it is a) out of scope for this PR and b) I'm not sure if this is actually wanted |
tests/core/io/test_pck_packer.h
Outdated
@@ -116,6 +134,25 @@ TEST_CASE("[PCKPacker] Pack a PCK file with some files and directories") { | |||
CHECK_MESSAGE( | |||
f->get_length() <= 27000, | |||
"The generated non-empty PCK file shouldn't be too large."); | |||
|
|||
// Now check the contents read with PCKReader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Full sentences should use punctuation.
I can't manage to build the crashing CI release locally. The compiler error mesage is Does anybody know what could be causing this? There's also a warning: Anyways I'll be going to bed now. I will try to continue debugging the crash tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't include it as it is a) out of scope for this PR and b) I'm not sure if this is actually wanted
Unlikely this is usefull for non-executable, and if somone realy want's it it's always possible to load it using
offset
.
CI crash is not related to your PR, we have it for some time but so far were not able to pinpoint the issue. So if it's happen, it's safe to restart the failed CI jobs.
core/io/pck_reader.cpp
Outdated
} | ||
|
||
void PCKReader::_bind_methods() { | ||
ClassDB::bind_method(D_METHOD("open", "path", "offset"), &PCKReader::open); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since PCK reader is user accessible, it might be worth adding the encryption key to the open
arguments (and fall back to the embedded key if it's empty).
21f8f8e
to
a8a6a0a
Compare
66a3826
to
f0fed34
Compare
Hi, Dragoncraft89! Built your fork and discovered a bunch of problems with it:
My system is Debian 11 (bullseye) if that helps. Tried with original PCK and exported using this fork. |
That is a known and solved bug, rebase your branch and test again: |
@ghmart Thanks for testing! Can you share a PCK file that does not work for you so that I can take a look? I'm not sure how I'd recreate your issue Regarding 4: I think godot does rename some files on export, so the PCKReader will only see the renamed filenames. Furthermore, text files are not packed into the pck by default. You may have to check your export settings whether txt files are included. Unfortunately I'm quite busy at the moment, so it'll take a couple of days for me to take a look at this. |
"3." - not about problem inside PCK. That's when you press "Export PCK/ZIP" and "Save a File" dialog opens up - it shows only several folders (random at a glance), not all that exists at that path or when you choose other path in filesystem (file / folder permissions are all identical).
You were right, thank you. Resources are stored in PCK in their import form. "Text files" - all *.tscn, *.gd and *.tres files can be loaded using "get_string_from_utf8". Can't figure out how to make "Image" or "ImageTexture" object from *.ctex or *s3tc.ctex file loaded into PackedByteArray by PCKReader. |
@ghmart I don't think 3 is due to my patch. As far as I know this is how Godot export always looked like. I think you have to disable the file filter on the export dialogue to see all files |
Updated the commit with the suggestion from @ghmart (setting default offset for the Rebased onto latest master, tested and still working. @ghmart I think I see what the issue with the file dialogue is. It treats directories the same as files for me. I couldn't find an open issue for that (or a mention somewhere that this was deliberate). So I will do a git bisect and open an issue for this. |
Any news on this? |
Adds a
PCKReader
class to read the contents of pck files without loading them.This class exposes the same interface as the
ZipReader
class. Therefore we now have the same interface asZIPPacker
/ZIPReader
for dealing with pck files.To do so, the PCK implementation of PackedSourcePCK has been extracted into a new
PCKFile
class. I also split the loading of normal pck files and the loading of embedded pck files. This seemed clearer to me. If you have any issues regarding this, feel free to tell me.Something to note would be that you cannot load the pck file embedded in the binary, as the
PCKReader
does not try to open the embedded file. But I'm not sure whether this should be supported as it feels quite hacky.Furthermore, the current implementation loads the file list to memory when opening. This way we do not need to parse the file list on each access.
Resolves godotengine/godot-proposals#1212