Mercurial > hg > openttd
changeset 10003:225c6c30e9b8 draft
(svn r14161) -Codechange: allow inis to be loaded from tars.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 24 Aug 2008 23:12:10 +0000 |
parents | 139ef0c97e94 |
children | 4e67bcb0c5b1 |
files | src/ini.cpp |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ini.cpp +++ b/src/ini.cpp @@ -8,6 +8,7 @@ #include "debug.h" #include "ini_type.h" #include "string_func.h" +#include "fileio.h" IniItem::IniItem(IniGroup *parent, const char *name, size_t len) : next(NULL), value(NULL), comment(NULL) { @@ -138,12 +139,14 @@ uint comment_size = 0; uint comment_alloc = 0; - FILE *in = fopen(filename, "r"); + size_t end; + FILE *in = FioFOpenFile(filename, "r", DATA_DIR, &end); if (in == NULL) return; + end += ftell(in); + /* for each line in the file */ - while (fgets(buffer, sizeof(buffer), in)) { - + while ((size_t)ftell(in) < end && fgets(buffer, sizeof(buffer), in)) { /* trim whitespace from the left side */ for (s = buffer; *s == ' ' || *s == '\t'; s++) {}