summaryrefslogtreecommitdiff
path: root/src/fileio.cpp
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-09-15 15:38:09 +0000
committertruelight <truelight@openttd.org>2007-09-15 15:38:09 +0000
commit6a8e5398a28aa2718a540785b60e8eb9e25a5387 (patch)
tree83a2b4a6872fa6984fe2b1b33abde269661aeb2b /src/fileio.cpp
parent17870089d0d834903f5a888019b2ee2cea62bea8 (diff)
downloadopenttd-6a8e5398a28aa2718a540785b60e8eb9e25a5387.tar.xz
(svn r11117) -Add: add support for 7z .tar files, which are in the 'old' (deprecated) format
Diffstat (limited to 'src/fileio.cpp')
-rw-r--r--src/fileio.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/fileio.cpp b/src/fileio.cpp
index 21d546291..e0299902e 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -349,7 +349,8 @@ FILE *FioTarFileList(const char *tar, const char *mode, size_t *filesize, FioTar
while (!feof(f)) {
/* Read the header and make sure it is a valid one */
fread(&th, 1, 512, f);
- if (strncmp(th.magic, "ustar", 5) != 0) return NULL;
+ /* 'ustar' is the new format, '\0' is the old format */
+ if (th.magic[0] != '\0' && strncmp(th.magic, "ustar", 5) != 0) return NULL;
name[0] = '\0';
int len = 0;
@@ -372,6 +373,9 @@ FILE *FioTarFileList(const char *tar, const char *mode, size_t *filesize, FioTar
buf[sizeof(th.size)] = '\0';
int skip = strtol(buf, &end, 8);
+ /* 0 byte sized files can be skipped (dirs, symlinks, ..) */
+ if (skip == 0) continue;
+
/* Check in the callback if this is the file we want */
if (callback(name, skip, userdata)) {
if (filesize != NULL) *filesize = skip;