@@ -24,6 +24,13 @@ constexpr std::string_view EXECUTABLE_EXTENSION2 = ".x86_64"; // | Godot
2424
2525class PackFile {
2626public:
27+ enum class OpenProperty {
28+ DECRYPTION_KEY, // The pack file is encrypted
29+ };
30+
31+ // Accepts the pack file GUID and request property, returns the requested value
32+ using OpenPropertyRequest = std::function<std::vector<std::byte>(std::string_view guid, OpenProperty property)>;
33+
2734 // / Accepts the entry's path and metadata
2835 template <typename R>
2936 using EntryCallbackBase = std::function<R(const std::string& path, const Entry& entry)>;
@@ -44,7 +51,7 @@ class PackFile {
4451 virtual ~PackFile () = default ;
4552
4653 // / Open a generic pack file. The parser is selected based on the file extension
47- [[nodiscard]] static std::unique_ptr<PackFile> open (const std::string& path, const EntryCallback& callback = nullptr );
54+ [[nodiscard]] static std::unique_ptr<PackFile> open (const std::string& path, const EntryCallback& callback = nullptr , const OpenPropertyRequest& requestProperty = nullptr );
4855
4956 // / Returns a sorted list of supported extensions for opening, e.g. {".bsp", ".vpk"}
5057 [[nodiscard]] static std::vector<std::string> getOpenableExtensions ();
@@ -116,7 +123,7 @@ class PackFile {
116123 void addDirectory (const std::string& entryBaseDir, const std::string& dir, EntryOptions options = {});
117124
118125 // / Adds new entries using the contents of a given directory
119- void addDirectory (const std::string& entryBaseDir , const std::string& dir, const EntryCreation& creation);
126+ void addDirectory (const std::string& entryBaseDir_ , const std::string& dir, const EntryCreation& creation);
120127
121128 // / Rename an existing entry
122129 virtual bool renameEntry (const std::string& oldPath_, const std::string& newPath_); // NOLINT(*-use-nodiscard)
@@ -210,10 +217,13 @@ class PackFile {
210217
211218 [[nodiscard]] static std::optional<std::vector<std::byte>> readUnbakedEntry (const Entry& entry);
212219
213- using OpenFactoryFunction = std::function<std::unique_ptr<PackFile>(const std::string& path, const EntryCallback& callback)>;
220+ using OpenFactoryFunctionBasic = std::function<std::unique_ptr<PackFile>(const std::string& path, const EntryCallback& callback)>;
221+ using OpenFactoryFunction = std::function<std::unique_ptr<PackFile>(const std::string& path, const EntryCallback& callback, const OpenPropertyRequest& requestProperty)>;
214222
215223 static std::unordered_map<std::string, std::vector<OpenFactoryFunction>>& getOpenExtensionRegistry ();
216224
225+ static const OpenFactoryFunction& registerOpenExtensionForTypeFactory (std::string_view extension, const OpenFactoryFunctionBasic& factory);
226+
217227 static const OpenFactoryFunction& registerOpenExtensionForTypeFactory (std::string_view extension, const OpenFactoryFunction& factory);
218228
219229 std::string fullFilePath;
0 commit comments