diff options
Diffstat (limited to 'crawl-ref/source/files.cc')
-rw-r--r-- | crawl-ref/source/files.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index bf82b47e10..2f845fff44 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -47,7 +47,6 @@ #ifdef __MINGW32__ #include <io.h> -#include <sys/types.h> #endif #include <sys/types.h> @@ -93,6 +92,12 @@ #include "view.h" #include "xom.h" +#ifndef HAVE_STAT +#if defined(UNIX) || defined(__MINGW32__) || defined(DOS) +#define HAVE_STAT +#endif +#endif + void save_level(int level_saved, level_area_type lt, branch_type where_were_you); @@ -288,11 +293,17 @@ void check_newer(const std::string &target, static bool file_exists(const std::string &name) { +#ifdef HAVE_STAT + struct stat st; + const int err = ::stat(name.c_str(), &st); + return (!err); +#else FILE *f = fopen(name.c_str(), "r"); const bool exists = !!f; if (f) fclose(f); return (exists); +#endif } // Low-tech existence check. @@ -369,8 +380,11 @@ std::string datafile_path(std::string basename, const std::string prefixes[] = { std::string("dat") + FILE_SEPARATOR, std::string("docs") + FILE_SEPARATOR, +#ifndef DATA_DIR_PATH std::string("..") + FILE_SEPARATOR + "docs" + FILE_SEPARATOR, + std::string("..") + FILE_SEPARATOR + "dat" + FILE_SEPARATOR, std::string("..") + FILE_SEPARATOR, +#endif std::string(".") + FILE_SEPARATOR, "", }; |