Also scroll tile separators in the train depot
[openttd/fttd.git] / src / tar_type.h
blob5496bb2bbec97dbac4473d6188c36902724ff8f2
1 /* $Id$ */
3 /*
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/>.
8 */
10 /** @file tar_type.h Structs, typedefs and macros used for TAR file handling. */
12 #ifndef TAR_TYPE_H
13 #define TAR_TYPE_H
15 #include <map>
16 #include <string>
18 #include "core/pointer.h"
19 #include "fileio_type.h"
21 /** The define of a TarList. */
22 struct TarListEntry {
23 ttd_unique_free_ptr <char> filename;
24 ttd_unique_free_ptr <char> dirname;
27 struct TarFileListEntry {
28 const char *tar_filename;
29 size_t size;
30 size_t position;
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. */
38 struct TarCache {
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 */