summaryrefslogtreecommitdiff
path: root/src/fileio.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
commit3d0ac9226701145b4e53559621987a799120baa8 (patch)
tree76979ef1579da87b2a015a8ddcae8cfc90a27748 /src/fileio.cpp
parentc0c12bca3d93b885bb704783a63f76a9aaa88794 (diff)
downloadopenttd-3d0ac9226701145b4e53559621987a799120baa8.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/fileio.cpp')
-rw-r--r--src/fileio.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/fileio.cpp b/src/fileio.cpp
index ad278e15f..2d1c01c71 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -267,7 +267,7 @@ char *FioGetDirectory(char *buf, size_t buflen, Subdirectory subdir)
return buf;
}
-FILE *FioFOpenFileSp(const char *filename, const char *mode, Searchpath sp, Subdirectory subdir)
+FILE *FioFOpenFileSp(const char *filename, const char *mode, Searchpath sp, Subdirectory subdir, size_t *filesize)
{
#if defined(WIN32) && defined(UNICODE)
/* fopen is implemented as a define with ellipses for
@@ -293,11 +293,17 @@ FILE *FioFOpenFileSp(const char *filename, const char *mode, Searchpath sp, Subd
f = fopen(buf, mode);
}
#endif
+ if (f != NULL && filesize != NULL) {
+ /* Find the size of the file */
+ fseek(f, 0, SEEK_END);
+ *filesize = ftell(f);
+ fseek(f, 0, SEEK_SET);
+ }
return f;
}
/** Opens OpenTTD files somewhere in a personal or global directory */
-FILE *FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir)
+FILE *FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir, size_t *size)
{
FILE *f = NULL;
Searchpath sp;
@@ -305,7 +311,7 @@ FILE *FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir)
assert(subdir < NUM_SUBDIRS || subdir == NO_DIRECTORY);
FOR_ALL_SEARCHPATHS(sp) {
- f = FioFOpenFileSp(filename, mode, sp, subdir);
+ f = FioFOpenFileSp(filename, mode, sp, subdir, size);
if (f != NULL || subdir == NO_DIRECTORY) break;
}