4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 /** @file tar_type.h Structs, typedefs and macros used for TAR file handling. */
18 #include "core/pointer.h"
19 #include "fileio_type.h"
21 /** The define of a TarList. */
23 ttd_unique_free_ptr
<char> filename
;
24 ttd_unique_free_ptr
<char> dirname
;
27 struct TarFileListEntry
{
28 const char *tar_filename
;
33 typedef std::map
<std::string
, TarListEntry
> TarList
;
34 typedef std::map
<std::string
, TarFileListEntry
> TarFileList
;
35 typedef std::map
<std::string
, std::string
> TarLinkList
;
37 /** Cache of tar files and their contents under a directory. */
39 TarList tars
; ///< list of tar files
40 TarFileList files
; ///< list of files in those tar files
41 TarLinkList links
; ///< list of directory links
43 void add_link (const std::string
&srcp
, const std::string
&destp
);
45 bool add (const char *filename
, size_t basepath_length
= 0);
47 bool extract (const char *filename
);
49 static TarCache cache
[NUM_SUBDIRS
]; ///< global per-directory cache
52 #define FOR_ALL_TARS(tar, sd) for (tar = TarCache::cache[sd].files.begin(); tar != TarCache::cache[sd].files.end(); tar++)
54 #endif /* TAR_TYPE_H */