# tar_type.h

Go to the documentation of this file.

    00001 /* $Id: tar_type.h 17248 2009-08-21 20:21:05Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * 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.
    00006  * 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.
    00007  * 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/>.
    00008  */
    00009
    00012 #ifndef TAR_TYPE_H
    00013 #define TAR_TYPE_H
    00014
    00015 #include <map>
    00016 #include <string>
    00017
    00019 struct TarListEntry {
    00020   const char *filename;
    00021   const char *dirname;
    00022
    00023   /* MSVC goes copying around this struct after initialisation, so it tries
    00024    * to free filename, which isn't set at that moment... but because it
    00025    * initializes the variable with garbage, it's going to segfault. */
    00026   TarListEntry() : filename(NULL), dirname(NULL) {}
    00027   ~TarListEntry() { free((void*)this->filename); free((void*)this->dirname); }
    00028 };
    00029
    00030 struct TarFileListEntry {
    00031   const char *tar_filename;
    00032   size_t size;
    00033   size_t position;
    00034 };
    00035
    00036 typedef std::map<std::string, TarListEntry> TarList;
    00037 typedef std::map<std::string, TarFileListEntry> TarFileList;
    00038 extern TarList _tar_list;
    00039 extern TarFileList _tar_filelist;
    00040
    00041 #define FOR_ALL_TARS(tar) for (tar = _tar_filelist.begin(); tar != _tar_filelist.end(); tar++)
    00042
    00043 typedef bool FioTarFileListCallback(const char *filename, int size, void *userdata);
    00044 FILE *FioTarFileList(const char *tar, const char *mode, size_t *filesize, FioTarFileListCallback *callback, void *userdata);
    00045
    00046 #endif /* TAR_TYPE_H */