summaryrefslogtreecommitdiff
path: root/src/fileio_func.h
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2018-05-20 03:55:06 +0200
committerMichael Lutz <michi@icosahedron.de>2018-05-26 22:28:01 +0200
commitce51e54d2692225226be7d03c79f96bbee4c4a87 (patch)
tree1553b8293cfbd10d3a31b2f857ee7bbcc6f55c68 /src/fileio_func.h
parent255549250f49522331b34ca693fb09c9d1807ac7 (diff)
downloadopenttd-ce51e54d2692225226be7d03c79f96bbee4c4a87.tar.xz
Change: [Win32] Parse and load DLS files for the DirectMusic driver without relying on high-level functions.
Diffstat (limited to 'src/fileio_func.h')
-rw-r--r--src/fileio_func.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/fileio_func.h b/src/fileio_func.h
index 443460b2d..2dc9afed1 100644
--- a/src/fileio_func.h
+++ b/src/fileio_func.h
@@ -149,4 +149,17 @@ static inline DIR *ttd_opendir(const char *path)
return opendir(OTTD2FS(path));
}
+
+/** Auto-close a file upon scope exit. */
+class FileCloser {
+ FILE *f;
+
+public:
+ FileCloser(FILE *_f) : f(_f) {}
+ ~FileCloser()
+ {
+ fclose(f);
+ }
+};
+
#endif /* FILEIO_FUNC_H */