summaryrefslogtreecommitdiff
path: root/src/gfxinit.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/gfxinit.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/gfxinit.cpp')
-rw-r--r--src/gfxinit.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index 408b5f623..86a16c391 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -114,7 +114,8 @@ static bool CheckMD5Digest(const MD5File file, md5_byte_t *digest, bool warn)
* returns true if the checksum is correct */
static bool FileMD5(const MD5File file, bool warn)
{
- FILE *f = FioFOpenFile(file.filename);
+ size_t size;
+ FILE *f = FioFOpenFile(file.filename, "rb", DATA_DIR, &size);
if (f != NULL) {
md5_state_t filemd5state;
@@ -123,8 +124,10 @@ static bool FileMD5(const MD5File file, bool warn)
size_t len;
md5_init(&filemd5state);
- 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(&filemd5state, buffer, len);
+ }
if (ferror(f) && warn) ShowInfoF("Error Reading from %s \n", file.filename);
fclose(f);