Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
Package.hpp
Go to the documentation of this file.
1/*
2Copyright (C) 2013,2018,2021,2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGAMES_PACKAGE_H
17#define AEONGAMES_PACKAGE_H
22#include <cstdint>
23#include <cstdio>
24#include <vector>
25#include <unordered_map>
26#include <string>
27#include <filesystem>
29namespace AeonGames
30{
33 {
34 NONE = 0,
36 };
37
38 struct PKGHeader
39 {
41 char id[8];
43 uint16_t version[2];
45 uint32_t file_size;
47 uint32_t file_count;
50 };
51
53 {
54 uint32_t path;
55 uint32_t offset;
57 uint64_t compressed_size;
60 };
61
64 class Package
65 {
66 public:
70 DLL Package ( const std::string& aPath );
72 DLL ~Package();
73 Package ( const Package& ) = delete;
74 Package& operator= ( const Package& ) = delete;
76 Package ( Package&& aPackage ) noexcept;
77 Package& operator= ( Package&& ) = delete;
81 DLL const std::filesystem::path& GetPath() const;
83 DLL size_t GetFileSize ( uint32_t crc ) const;
85 DLL size_t GetFileSize ( const std::string& aFileName ) const;
89 DLL const std::unordered_map<uint32_t, std::string>& GetIndexTable() const;
91 DLL void LoadFile ( uint32_t crc, void* buffer, size_t buffer_size ) const;
93 DLL void LoadFile ( const std::string& aFileName, void* buffer, size_t buffer_size ) const;
94 private:
96 const std::filesystem::path mPath;
97 std::unordered_map<uint32_t, std::string> mIndexTable;
98 };
99}
100#endif
Platform-specific macros, includes, and DLL export/import definitions.
DLL const std::filesystem::path & GetPath() const
Get the path associated with this package.
Definition Package.cpp:111
DLL size_t GetFileSize(uint32_t crc) const
Definition Package.cpp:119
DLL void LoadFile(uint32_t crc, void *buffer, size_t buffer_size) const
Definition Package.cpp:139
DLL ~Package()
Destructor.
DLL const std::unordered_map< uint32_t, std::string > & GetIndexTable() const
Get the package index table.
Definition Package.cpp:115
DLL Package(const std::string &aPath)
Construct a Package from a file path.
Definition Package.cpp:89
<- This is here just for the literals
Definition AABB.hpp:31
PKGCompressionTypes
Compression types supported by PKG packages.
Definition Package.hpp:33
@ ZLIB
ZLIB compression.
Definition Package.hpp:35
@ NONE
No compression.
Definition Package.hpp:34
Directory entry describing a single file within a PKG package.
Definition Package.hpp:53
uint64_t uncompressed_size
Original size of the file data before compression.
Definition Package.hpp:58
uint32_t path
Offset into the string table for the file path.
Definition Package.hpp:54
uint64_t compression_type
Compression algorithm used (see PKGCompressionTypes).
Definition Package.hpp:59
uint32_t offset
Byte offset of the file data within the package.
Definition Package.hpp:55
uint64_t compressed_size
Size of the file data after compression.
Definition Package.hpp:57
uint64_t extension_offset
Offset to the file extension in the string table.
Definition Package.hpp:56
Header for PKG Files.
Definition Package.hpp:39
uint32_t file_count
Number of files contained in this package.
Definition Package.hpp:47
uint32_t string_table_offset
String table offset.
Definition Package.hpp:49
uint32_t file_size
Package size.
Definition Package.hpp:45
uint16_t version[2]
File Version version[0] = mayor, version[1] = minor.
Definition Package.hpp:43