(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
--- a/projects/openttd_vs80.vcproj Sun Aug 31 09:52:47 2008 +0000
+++ b/projects/openttd_vs80.vcproj Sun Aug 31 10:50:05 2008 +0000
@@ -992,7 +992,11 @@
>
</File>
<File
- RelativePath=".\..\src\fileio.h"
+ RelativePath=".\..\src\fileio_func.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\fileio_type.h"
>
</File>
<File
--- a/projects/openttd_vs90.vcproj Sun Aug 31 09:52:47 2008 +0000
+++ b/projects/openttd_vs90.vcproj Sun Aug 31 10:50:05 2008 +0000
@@ -989,7 +989,11 @@
>
</File>
<File
- RelativePath=".\..\src\fileio.h"
+ RelativePath=".\..\src\fileio_func.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\fileio_type.h"
>
</File>
<File
--- a/source.list Sun Aug 31 09:52:47 2008 +0000
+++ b/source.list Sun Aug 31 10:50:05 2008 +0000
@@ -175,7 +175,8 @@
engine_gui.h
engine_type.h
fiber.hpp
-fileio.h
+fileio_func.h
+fileio_type.h
fios.h
fontcache.h
functions.h
--- a/src/console_cmds.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/console_cmds.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -15,7 +15,7 @@
#include "command_func.h"
#include "settings_func.h"
#include "fios.h"
-#include "fileio.h"
+#include "fileio_func.h"
#include "screenshot.h"
#include "genworld.h"
#include "strings_func.h"
--- a/src/fileio.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/fileio.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -4,7 +4,7 @@
#include "stdafx.h"
#include "openttd.h"
-#include "fileio.h"
+#include "fileio_func.h"
#include "variables.h"
#include "debug.h"
#include "fios.h"
--- a/src/fileio.h Sun Aug 31 09:52:47 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/* $Id$ */
-
-/** @file fileio.h Declarations for Standard In/Out file operations */
-
-#ifndef FILEIO_H
-#define FILEIO_H
-
-#include "core/enum_type.hpp"
-
-void FioSeekTo(size_t pos, int mode);
-void FioSeekToFile(uint8 slot, size_t pos);
-size_t FioGetPos();
-const char *FioGetFilename(uint8 slot);
-byte FioReadByte();
-uint16 FioReadWord();
-uint32 FioReadDword();
-void FioCloseAll();
-void FioOpenFile(int slot, const char *filename);
-void FioReadBlock(void *ptr, size_t size);
-void FioSkipBytes(int n);
-void FioCreateDirectory(const char *filename);
-
-/**
- * The different kinds of subdirectories OpenTTD uses
- */
-enum Subdirectory {
- BASE_DIR, ///< Base directory for all subdirectories
- SAVE_DIR, ///< Base directory for all savegames
- AUTOSAVE_DIR, ///< Subdirectory of save for autosaves
- SCENARIO_DIR, ///< Base directory for all scenarios
- HEIGHTMAP_DIR, ///< Subdirectory of scenario for heightmaps
- GM_DIR, ///< Subdirectory for all music
- DATA_DIR, ///< Subdirectory for all data (GRFs, sample.cat, intro game)
- LANG_DIR, ///< Subdirectory for all translation files
- NUM_SUBDIRS, ///< Number of subdirectories
- NO_DIRECTORY, ///< A path without any base directory
-};
-
-/**
- * Types of searchpaths OpenTTD might use
- */
-enum Searchpath {
- SP_FIRST_DIR,
- SP_WORKING_DIR = SP_FIRST_DIR, ///< Search in the working directory
- SP_PERSONAL_DIR, ///< Search in the personal directory
- SP_SHARED_DIR, ///< Search in the shared directory, like 'Shared Files' under Windows
- SP_BINARY_DIR, ///< Search in the directory where the binary resides
- SP_INSTALLATION_DIR, ///< Search in the installation directory
- SP_APPLICATION_BUNDLE_DIR, ///< Search within the application bundle
- NUM_SEARCHPATHS
-};
-
-DECLARE_POSTFIX_INCREMENT(Searchpath);
-
-/**
- * The searchpaths OpenTTD could search through.
- * At least one of the slots has to be filled with a path.
- * NULL paths tell that there is no such path for the
- * current operating system.
- */
-extern const char *_searchpaths[NUM_SEARCHPATHS];
-
-/**
- * Checks whether the given search path is a valid search path
- * @param sp the search path to check
- * @return true if the search path is valid
- */
-static inline bool IsValidSearchPath(Searchpath sp)
-{
- return sp < NUM_SEARCHPATHS && _searchpaths[sp] != NULL;
-}
-
-/** Iterator for all the search paths */
-#define FOR_ALL_SEARCHPATHS(sp) for (sp = SP_FIRST_DIR; sp < NUM_SEARCHPATHS; sp++) if (IsValidSearchPath(sp))
-
-void FioFCloseFile(FILE *f);
-FILE *FioFOpenFile(const char *filename, const char *mode = "rb", Subdirectory subdir = DATA_DIR, size_t *filesize = NULL);
-bool FioCheckFileExists(const char *filename, Subdirectory subdir = DATA_DIR);
-char *FioGetFullPath(char *buf, size_t buflen, Searchpath sp, Subdirectory subdir, const char *filename);
-char *FioFindFullPath(char *buf, size_t buflen, Subdirectory subdir, const char *filename);
-char *FioAppendDirectory(char *buf, size_t buflen, Searchpath sp, Subdirectory subdir);
-char *FioGetDirectory(char *buf, size_t buflen, Subdirectory subdir);
-
-static inline const char *FioGetSubdirectory(Subdirectory subdir)
-{
- extern const char *_subdirs[NUM_SUBDIRS];
- assert(subdir < NUM_SUBDIRS);
- return _subdirs[subdir];
-}
-
-void SanitizeFilename(char *filename);
-void AppendPathSeparator(char *buf, size_t buflen);
-void DeterminePaths(const char *exe);
-void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize);
-bool FileExists(const char *filename);
-
-extern char *_personal_dir; ///< custom directory for personal settings, saves, newgrf, etc.
-
-/** Helper for scanning for files with a given name */
-class FileScanner
-{
-public:
- uint Scan(const char *extension, Subdirectory sd, bool tars = true);
-
- /**
- * Add a file with the given filename.
- * @param filename the full path to the file to read
- * @param basepath_length amount of characters to chop of before to get a
- * filename relative to the search path.
- * @return true if the file is added.
- */
- virtual bool AddFile(const char *filename, size_t basepath_length) = 0;
-};
-
-#endif /* FILEIO_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fileio_func.h Sun Aug 31 10:50:05 2008 +0000
@@ -0,0 +1,131 @@
+/* $Id$ */
+
+/** @file fileio_func.h Functions for Standard In/Out file operations */
+
+#ifndef FILEIO_FUNC_H
+#define FILEIO_FUNC_H
+
+#include "fileio_type.h"
+
+void FioSeekTo(size_t pos, int mode);
+void FioSeekToFile(uint8 slot, size_t pos);
+size_t FioGetPos();
+const char *FioGetFilename(uint8 slot);
+byte FioReadByte();
+uint16 FioReadWord();
+uint32 FioReadDword();
+void FioCloseAll();
+void FioOpenFile(int slot, const char *filename);
+void FioReadBlock(void *ptr, size_t size);
+void FioSkipBytes(int n);
+void FioCreateDirectory(const char *filename);
+
+/**
+ * The searchpaths OpenTTD could search through.
+ * At least one of the slots has to be filled with a path.
+ * NULL paths tell that there is no such path for the
+ * current operating system.
+ */
+extern const char *_searchpaths[NUM_SEARCHPATHS];
+
+/**
+ * Checks whether the given search path is a valid search path
+ * @param sp the search path to check
+ * @return true if the search path is valid
+ */
+static inline bool IsValidSearchPath(Searchpath sp)
+{
+ return sp < NUM_SEARCHPATHS && _searchpaths[sp] != NULL;
+}
+
+/** Iterator for all the search paths */
+#define FOR_ALL_SEARCHPATHS(sp) for (sp = SP_FIRST_DIR; sp < NUM_SEARCHPATHS; sp++) if (IsValidSearchPath(sp))
+
+void FioFCloseFile(FILE *f);
+FILE *FioFOpenFile(const char *filename, const char *mode = "rb", Subdirectory subdir = DATA_DIR, size_t *filesize = NULL);
+bool FioCheckFileExists(const char *filename, Subdirectory subdir = DATA_DIR);
+char *FioGetFullPath(char *buf, size_t buflen, Searchpath sp, Subdirectory subdir, const char *filename);
+char *FioFindFullPath(char *buf, size_t buflen, Subdirectory subdir, const char *filename);
+char *FioAppendDirectory(char *buf, size_t buflen, Searchpath sp, Subdirectory subdir);
+char *FioGetDirectory(char *buf, size_t buflen, Subdirectory subdir);
+
+static inline const char *FioGetSubdirectory(Subdirectory subdir)
+{
+ extern const char *_subdirs[NUM_SUBDIRS];
+ assert(subdir < NUM_SUBDIRS);
+ return _subdirs[subdir];
+}
+
+void SanitizeFilename(char *filename);
+void AppendPathSeparator(char *buf, size_t buflen);
+void DeterminePaths(const char *exe);
+void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize);
+bool FileExists(const char *filename);
+
+extern char *_personal_dir; ///< custom directory for personal settings, saves, newgrf, etc.
+
+/** Helper for scanning for files with a given name */
+class FileScanner
+{
+public:
+ uint Scan(const char *extension, Subdirectory sd, bool tars = true);
+
+ /**
+ * Add a file with the given filename.
+ * @param filename the full path to the file to read
+ * @param basepath_length amount of characters to chop of before to get a
+ * filename relative to the search path.
+ * @return true if the file is added.
+ */
+ virtual bool AddFile(const char *filename, size_t basepath_length) = 0;
+};
+
+
+/* Implementation of opendir/readdir/closedir for Windows */
+#if defined(WIN32)
+#include <windows.h>
+struct DIR;
+
+struct dirent { // XXX - only d_name implemented
+ TCHAR *d_name; // name of found file
+ /* little hack which will point to parent DIR struct which will
+ * save us a call to GetFileAttributes if we want information
+ * about the file (for example in function fio_bla) */
+ DIR *dir;
+};
+
+struct DIR {
+ HANDLE hFind;
+ /* the dirent returned by readdir.
+ * note: having only one global instance is not possible because
+ * multiple independent opendir/readdir sequences must be supported. */
+ dirent ent;
+ WIN32_FIND_DATA fd;
+ /* since opendir calls FindFirstFile, we need a means of telling the
+ * first call to readdir that we already have a file.
+ * that's the case iff this is true */
+ bool at_first_entry;
+};
+
+DIR *opendir(const TCHAR *path);
+struct dirent *readdir(DIR *d);
+int closedir(DIR *d);
+#else
+/* Use system-supplied opendir/readdir/closedir functions */
+# include <sys/types.h>
+# include <dirent.h>
+#endif /* defined(WIN32) */
+
+/**
+ * A wrapper around opendir() which will convert the string from
+ * OPENTTD encoding to that of the filesystem. For all purposes this
+ * function behaves the same as the original opendir function
+ * @param path string to open directory of
+ * @return DIR pointer
+ */
+static inline DIR *ttd_opendir(const char *path)
+{
+ return opendir(OTTD2FS(path));
+}
+
+#endif /* FILEIO_FUNC_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fileio_type.h Sun Aug 31 10:50:05 2008 +0000
@@ -0,0 +1,42 @@
+/* $Id$ */
+
+/** @file fileio_type.h Types for Standard In/Out file operations */
+
+#ifndef FILEIO_TYPE_H
+#define FILEIO_TYPE_H
+
+#include "core/enum_type.hpp"
+
+/**
+ * The different kinds of subdirectories OpenTTD uses
+ */
+enum Subdirectory {
+ BASE_DIR, ///< Base directory for all subdirectories
+ SAVE_DIR, ///< Base directory for all savegames
+ AUTOSAVE_DIR, ///< Subdirectory of save for autosaves
+ SCENARIO_DIR, ///< Base directory for all scenarios
+ HEIGHTMAP_DIR, ///< Subdirectory of scenario for heightmaps
+ GM_DIR, ///< Subdirectory for all music
+ DATA_DIR, ///< Subdirectory for all data (GRFs, sample.cat, intro game)
+ LANG_DIR, ///< Subdirectory for all translation files
+ NUM_SUBDIRS, ///< Number of subdirectories
+ NO_DIRECTORY, ///< A path without any base directory
+};
+
+/**
+ * Types of searchpaths OpenTTD might use
+ */
+enum Searchpath {
+ SP_FIRST_DIR,
+ SP_WORKING_DIR = SP_FIRST_DIR, ///< Search in the working directory
+ SP_PERSONAL_DIR, ///< Search in the personal directory
+ SP_SHARED_DIR, ///< Search in the shared directory, like 'Shared Files' under Windows
+ SP_BINARY_DIR, ///< Search in the directory where the binary resides
+ SP_INSTALLATION_DIR, ///< Search in the installation directory
+ SP_APPLICATION_BUNDLE_DIR, ///< Search within the application bundle
+ NUM_SEARCHPATHS
+};
+
+DECLARE_POSTFIX_INCREMENT(Searchpath);
+
+#endif /* FILEIO_TYPE_H */
--- a/src/fios.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/fios.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -9,7 +9,7 @@
#include "variables.h"
#include "heightmap.h"
#include "fios.h"
-#include "fileio.h"
+#include "fileio_func.h"
#include "functions.h"
#include "string_func.h"
#include <sys/types.h>
--- a/src/fios.h Sun Aug 31 09:52:47 2008 +0000
+++ b/src/fios.h Sun Aug 31 10:50:05 2008 +0000
@@ -110,51 +110,4 @@
int CDECL compare_FiosItems(const void *a, const void *b);
-/* Implementation of opendir/readdir/closedir for Windows */
-#if defined(WIN32)
-#include <windows.h>
-struct DIR;
-
-struct dirent { // XXX - only d_name implemented
- TCHAR *d_name; // name of found file
- /* little hack which will point to parent DIR struct which will
- * save us a call to GetFileAttributes if we want information
- * about the file (for example in function fio_bla) */
- DIR *dir;
-};
-
-struct DIR {
- HANDLE hFind;
- /* the dirent returned by readdir.
- * note: having only one global instance is not possible because
- * multiple independent opendir/readdir sequences must be supported. */
- dirent ent;
- WIN32_FIND_DATA fd;
- /* since opendir calls FindFirstFile, we need a means of telling the
- * first call to readdir that we already have a file.
- * that's the case iff this is true */
- bool at_first_entry;
-};
-
-DIR *opendir(const TCHAR *path);
-struct dirent *readdir(DIR *d);
-int closedir(DIR *d);
-#else
-/* Use system-supplied opendir/readdir/closedir functions */
-# include <sys/types.h>
-# include <dirent.h>
-#endif /* defined(WIN32) */
-
-/**
- * A wrapper around opendir() which will convert the string from
- * OPENTTD encoding to that of the filesystem. For all purposes this
- * function behaves the same as the original opendir function
- * @param path string to open directory of
- * @return DIR pointer
- */
-static inline DIR *ttd_opendir(const char *path)
-{
- return opendir(OTTD2FS(path));
-}
-
#endif /* FIOS_H */
--- a/src/gfxinit.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/gfxinit.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -7,7 +7,7 @@
#include "debug.h"
#include "gfxinit.h"
#include "spritecache.h"
-#include "fileio.h"
+#include "fileio_func.h"
#include "fios.h"
#include "newgrf.h"
#include "md5.h"
--- a/src/ini.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/ini.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -8,7 +8,7 @@
#include "debug.h"
#include "ini_type.h"
#include "string_func.h"
-#include "fileio.h"
+#include "fileio_func.h"
IniItem::IniItem(IniGroup *parent, const char *name, size_t len) : next(NULL), value(NULL), comment(NULL)
{
--- a/src/misc_gui.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/misc_gui.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -30,7 +30,7 @@
#include "cargotype.h"
#include "player_face.h"
#include "strings_func.h"
-#include "fileio.h"
+#include "fileio_func.h"
#include "fios.h"
#include "tile_cmd.h"
#include "zoom_func.h"
--- a/src/music_gui.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/music_gui.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -4,7 +4,7 @@
#include "stdafx.h"
#include "openttd.h"
-#include "fileio.h"
+#include "fileio_func.h"
#include "variables.h"
#include "music.h"
#include "music/music_driver.hpp"
--- a/src/network/network.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/network/network.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -28,7 +28,6 @@
#include "../console_func.h"
#include <stdarg.h> /* va_list */
#include "../md5.h"
-#include "../fileio.h"
#include "../texteff.hpp"
#include "../core/random_func.hpp"
#include "../window_func.h"
--- a/src/network/network_client.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/network/network_client.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -18,7 +18,7 @@
#include "../variables.h"
#include "../ai/ai.h"
#include "../core/alloc_func.hpp"
-#include "../fileio.h"
+#include "../fileio_func.h"
#include "../md5.h"
#include "../strings_func.h"
#include "../window_func.h"
--- a/src/network/network_server.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/network/network_server.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -22,7 +22,7 @@
#include "../variables.h"
#include "../genworld.h"
#include "../core/alloc_func.hpp"
-#include "../fileio.h"
+#include "../fileio_func.h"
#include "../string_func.h"
#include "../player_base.h"
#include "../player_func.h"
--- a/src/newgrf.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/newgrf.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -8,7 +8,7 @@
#include "openttd.h"
#include "debug.h"
-#include "fileio.h"
+#include "fileio_func.h"
#include "engine_func.h"
#include "engine_base.h"
#include "spritecache.h"
--- a/src/newgrf_config.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/newgrf_config.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -15,7 +15,7 @@
#include "gamelog.h"
#include "network/network_type.h"
-#include "fileio.h"
+#include "fileio_func.h"
#include "fios.h"
--- a/src/openttd.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/openttd.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -33,7 +33,7 @@
#include "town.h"
#include "industry.h"
#include "news_func.h"
-#include "fileio.h"
+#include "fileio_func.h"
#include "fios.h"
#include "airport.h"
#include "aircraft.h"
--- a/src/saveload.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/saveload.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -31,6 +31,7 @@
#include "vehicle_base.h"
#include "autoreplace_base.h"
#include "statusbar_gui.h"
+#include "fileio_func.h"
#include <list>
#include "gamelog.h"
--- a/src/saveload.h Sun Aug 31 09:52:47 2008 +0000
+++ b/src/saveload.h Sun Aug 31 10:50:05 2008 +0000
@@ -5,7 +5,7 @@
#ifndef SAVELOAD_H
#define SAVELOAD_H
-#include "fileio.h"
+#include "fileio_type.h"
#ifdef SIZE_MAX
#undef SIZE_MAX
--- a/src/screenshot.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/screenshot.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -5,14 +5,13 @@
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
-#include "fileio.h"
+#include "fileio_func.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "core/math_func.hpp"
#include "screenshot.h"
#include "variables.h"
#include "blitter/factory.hpp"
-#include "fileio.h"
#include "strings_func.h"
#include "zoom_func.h"
#include "core/alloc_func.hpp"
--- a/src/sound.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/sound.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -7,7 +7,7 @@
#include "landscape.h"
#include "mixer.h"
#include "sound_func.h"
-#include "fileio.h"
+#include "fileio_func.h"
#include "newgrf_sound.h"
#include "fios.h"
#include "window_gui.h"
--- a/src/spritecache.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/spritecache.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -7,7 +7,7 @@
#include "variables.h"
#include "debug.h"
#include "spritecache.h"
-#include "fileio.h"
+#include "fileio_func.h"
#include "spriteloader/grf.hpp"
#include "core/alloc_func.hpp"
#include "core/math_func.hpp"
--- a/src/spriteloader/grf.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/spriteloader/grf.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -4,7 +4,7 @@
#include "../stdafx.h"
#include "../gfx_func.h"
-#include "../fileio.h"
+#include "../fileio_func.h"
#include "../debug.h"
#include "../core/alloc_func.hpp"
#include "grf.hpp"
--- a/src/spriteloader/png.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/spriteloader/png.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -6,7 +6,7 @@
#include "../stdafx.h"
#include "../gfx_func.h"
-#include "../fileio.h"
+#include "../fileio_func.h"
#include "../debug.h"
#include "../core/alloc_func.hpp"
#include "png.hpp"
--- a/src/strings.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/strings.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -15,7 +15,7 @@
#include "newgrf_text.h"
#include "music.h"
#include "industry.h"
-#include "fileio.h"
+#include "fileio_func.h"
#include "cargotype.h"
#include "group.h"
#include "debug.h"
--- a/src/video/dedicated_v.cpp Sun Aug 31 09:52:47 2008 +0000
+++ b/src/video/dedicated_v.cpp Sun Aug 31 10:50:05 2008 +0000
@@ -14,7 +14,7 @@
#include "../console_func.h"
#include "../variables.h"
#include "../genworld.h"
-#include "../fileio.h"
+#include "../fileio_type.h"
#include "../fios.h"
#include "../blitter/factory.hpp"
#include "../core/alloc_func.hpp"