summaryrefslogtreecommitdiff
path: root/src/newgrf_config.cpp
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-09-13 18:46:29 +0000
committertruelight <truelight@openttd.org>2007-09-13 18:46:29 +0000
commitb84bd3cd1caf1c4b1fb534433e8a83bc789bf424 (patch)
tree76979ef1579da87b2a015a8ddcae8cfc90a27748 /src/newgrf_config.cpp
parent45a1ad524adc969cac39a03d83f6369b6a5d917e (diff)
downloadopenttd-b84bd3cd1caf1c4b1fb534433e8a83bc789bf424.tar.xz
(svn r11099) -Codechange: allow on opening of a file via FioFOpenFile to request the size of the file, so we can keep that in mind
Diffstat (limited to 'src/newgrf_config.cpp')
-rw-r--r--src/newgrf_config.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index f320d2c05..acd471d64 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -37,15 +37,16 @@ static bool CalcGRFMD5Sum(GRFConfig *config)
FILE *f;
md5_state_t md5state;
md5_byte_t buffer[1024];
- size_t len;
+ size_t len, size;
/* open the file */
- f = FioFOpenFile(config->filename);
+ f = FioFOpenFile(config->filename, "rb", DATA_DIR, &size);
if (f == NULL) return false;
/* calculate md5sum */
md5_init(&md5state);
- while ((len = fread(buffer, 1, sizeof(buffer), f)) != 0) {
+ while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, f)) != 0 && size != 0) {
+ size -= len;
md5_append(&md5state, buffer, len);
}
md5_finish(&md5state, config->md5sum);