summaryrefslogtreecommitdiff
path: root/src/ini.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-08-24 23:12:10 +0000
committerrubidium <rubidium@openttd.org>2008-08-24 23:12:10 +0000
commitb2d6254b44de862744f539373e7fb57787a7423d (patch)
tree2b7839f2627b86c8c4c837e1e0164ecaf0b0e29d /src/ini.cpp
parentb45ced35eea5caed622fd93f460d90378326daf7 (diff)
downloadopenttd-b2d6254b44de862744f539373e7fb57787a7423d.tar.xz
(svn r14161) -Codechange: allow inis to be loaded from tars.
Diffstat (limited to 'src/ini.cpp')
-rw-r--r--src/ini.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/ini.cpp b/src/ini.cpp
index 764755f0b..86cceaa42 100644
--- 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 @@ void IniFile::LoadFromDisk(const char *filename)
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;
- /* for each line in the file */
- while (fgets(buffer, sizeof(buffer), in)) {
+ end += ftell(in);
+ /* for each line in the file */
+ while ((size_t)ftell(in) < end && fgets(buffer, sizeof(buffer), in)) {
/* trim whitespace from the left side */
for (s = buffer; *s == ' ' || *s == '\t'; s++) {}