Merge 'remotes/trunk'
[0ad.git] / source / ps / ArchiveBuilder.h
blob3e578e6345d0a30473e588da00ef637286ebb9d8
1 /* Copyright (C) 2014 Wildfire Games.
2 * This file is part of 0 A.D.
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.
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.
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/>.
18 #ifndef INCLUDED_ARCHIVEBUILDER
19 #define INCLUDED_ARCHIVEBUILDER
21 #include "lib/file/vfs/vfs.h"
22 #include "ps/CStr.h"
24 /**
25 * Packages a mod's files into a distributable archive.
26 * This includes various game-specific knowledge on how to convert
27 * and cache certain files into more efficient formats (PNG -> DDS, etc).
29 class CArchiveBuilder
31 public:
32 /**
33 * Initialise the archive builder for processing the given mod.
34 * Assumes no graphics code (especially tex_codec) has been initialised yet.
36 * @param mod path to data/mods/foo directory, containing files for conversion
37 * @param tempdir path to a writable directory for temporary files
39 CArchiveBuilder(const OsPath& mod, const OsPath& tempdir);
41 ~CArchiveBuilder();
43 /**
44 * Add a mod which will be loaded but not archived, to provide
45 * files like textures.xml needed for the conversion.
46 * Added mods will be mounted with increasing priority.
47 * Typically this will be called with 'public', when packaging
48 * a user's mod.
49 * @param mod path to data/mods/foo directory, containing files for loading
51 void AddBaseMod(const OsPath& mod);
53 /**
54 * Do all the processing and packing of files into the archive.
55 * @param archive path of .zip file to generate (will be overwritten if it exists)
56 * @param compress whether to compress the contents of the .zip file
58 void Build(const OsPath& archive, bool compress);
60 private:
61 static Status CollectFileCB(const VfsPath& pathname, const CFileInfo& fileInfo, const uintptr_t cbData);
63 PIVFS m_VFS;
64 std::vector<VfsPath> m_Files;
65 OsPath m_TempDir;
66 size_t m_NumBaseMods;
69 #endif // INCLUDED_ARCHIVEBUILDER