(svn r11106) -Add: added .tar support; you can pack all files in your data/ dir in how ever many .tar files you like, keeping the dir-structure equal to the unpacked version, and OpenTTD can handle them just like the files were unpacked

-Note: useful for GRF-packs and 32bpp PNGs. Don't forget to keep the dir-structure alive for 32bpp PNGs!
  -Note: file-loading-order: search-paths, .tar-files in the order found on disk (can be anything at all, don't depend on it.. use 'openttd -d1' to see which order they are added)
This commit is contained in:
truelight
2007-09-14 22:25:00 +00:00
parent b25c661ce6
commit 5647bd5157
3 changed files with 208 additions and 0 deletions

View File

@@ -6,6 +6,7 @@
#define FILEIO_H
#include "helpers.hpp"
#include <list>
void FioSeekTo(uint32 pos, int mode);
void FioSeekToFile(uint8 slot, uint32 pos);
@@ -60,6 +61,11 @@ DECLARE_POSTFIX_INCREMENT(Searchpath);
*/
extern const char *_searchpaths[NUM_SEARCHPATHS];
/**
* All the tar-files OpenTTD could search through.
*/
extern std::list<const char *>_tar_list;
/**
* Checks whether the given search path is a valid search path
* @param sp the search path to check
@@ -72,6 +78,10 @@ static inline bool IsValidSearchPath(Searchpath sp)
/** Iterator for all the search paths */
#define FOR_ALL_SEARCHPATHS(sp) for (sp = SP_FIRST_DIR; sp < NUM_SEARCHPATHS; sp++) if (IsValidSearchPath(sp))
#define FOR_ALL_TARS(tar) for (std::list<const char *>::iterator it = _tar_list.begin(); it != _tar_list.end(); it++) if (tar = *it, true)
typedef bool FioTarFileListCallback(const char *filename, int size, void *userdata);
FILE *FioTarFileList(const char *tar, const char *mode, size_t *filesize, FioTarFileListCallback *callback, void *userdata);
FILE *FioFOpenFile(const char *filename, const char *mode = "rb", Subdirectory subdir = DATA_DIR, size_t *filesize = NULL);
bool FioCheckFileExists(const char *filename, Subdirectory subdir = DATA_DIR);