Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
ArchiveBuilder.h
Go to the documentation of this file.
1/* Copyright (C) 2025 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_ARCHIVEBUILDER
19#define INCLUDED_ARCHIVEBUILDER
20
21#include "lib/file/vfs/vfs.h"
23#include "lib/os_path.h"
24#include "lib/status.h"
25
26#include <cstddef>
27#include <cstdint>
28#include <vector>
29
30class CFileInfo;
31
32/**
33 * Packages a mod's files into a distributable archive.
34 * This includes various game-specific knowledge on how to convert
35 * and cache certain files into more efficient formats (PNG -> DDS, etc).
36 */
38{
39public:
40 /**
41 * Initialise the archive builder for processing the given mod.
42 * Assumes no graphics code (especially tex_codec) has been initialised yet.
43 *
44 * @param mod path to data/mods/foo directory, containing files for conversion
45 * @param tempdir path to a writable directory for temporary files
46 */
47 CArchiveBuilder(const OsPath& mod, const OsPath& tempdir);
48
50
51 /**
52 * Add a mod which will be loaded but not archived, to provide
53 * files like textures.xml needed for the conversion.
54 * Added mods will be mounted with increasing priority.
55 * Typically this will be called with 'public', when packaging
56 * a user's mod.
57 * @param mod path to data/mods/foo directory, containing files for loading
58 */
59 void AddBaseMod(const OsPath& mod);
60
61 /**
62 * Do all the processing and packing of files into the archive.
63 * @param archive path of .zip file to generate (will be overwritten if it exists)
64 * @param compress whether to compress the contents of the .zip file
65 */
66 void Build(const OsPath& archive, bool compress);
67
68private:
69 static Status CollectFileCB(const VfsPath& pathname, const CFileInfo& fileInfo, const uintptr_t cbData);
70
72 std::vector<VfsPath> m_Files;
75};
76
77#endif // INCLUDED_ARCHIVEBUILDER
Packages a mod's files into a distributable archive.
Definition: ArchiveBuilder.h:38
OsPath m_TempDir
Definition: ArchiveBuilder.h:73
std::vector< VfsPath > m_Files
Definition: ArchiveBuilder.h:72
CArchiveBuilder(const OsPath &mod, const OsPath &tempdir)
Initialise the archive builder for processing the given mod.
Definition: ArchiveBuilder.cpp:37
void Build(const OsPath &archive, bool compress)
Do all the processing and packing of files into the archive.
Definition: ArchiveBuilder.cpp:67
size_t m_NumBaseMods
Definition: ArchiveBuilder.h:74
void AddBaseMod(const OsPath &mod)
Add a mod which will be loaded but not archived, to provide files like textures.xml needed for the co...
Definition: ArchiveBuilder.cpp:60
PIVFS m_VFS
Definition: ArchiveBuilder.h:71
~CArchiveBuilder()
Definition: ArchiveBuilder.cpp:53
static Status CollectFileCB(const VfsPath &pathname, const CFileInfo &fileInfo, const uintptr_t cbData)
Definition: ArchiveBuilder.cpp:182
Definition: file_system.h:41
Definition: path.h:84
std::int64_t Status
Error handling system.
Definition: status.h:174
std::shared_ptr< IVFS > PIVFS
Definition: vfs.h:240