diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d4b67c..0286e98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,8 +206,8 @@ set(PDF2HTMLEX_SRC ${PDF2HTMLEX_SRC} src/util/path.cc src/util/unicode.h src/util/unicode.cc - src/util/win32.h - src/util/win32.cc + src/util/mingw.h + src/util/mingw.cc src/ArgParser.h src/ArgParser.cc src/Base64Stream.h diff --git a/src/TmpFiles.cc b/src/TmpFiles.cc index 1cc9e22..cecd90d 100644 --- a/src/TmpFiles.cc +++ b/src/TmpFiles.cc @@ -14,7 +14,10 @@ #include "TmpFiles.h" #include "Param.h" -#include "util/win32.h" + +#ifdef __MINGW32__ +#include "util/mingw.h" +#endif using namespace std; diff --git a/src/pdf2htmlEX.cc b/src/pdf2htmlEX.cc index 68546d8..1f306c2 100644 --- a/src/pdf2htmlEX.cc +++ b/src/pdf2htmlEX.cc @@ -35,7 +35,10 @@ #include "util/path.h" #include "util/ffw.h" -#include "util/win32.h" + +#ifdef __MINGW32__ +#include "util/mingw.h" +#endif using namespace std; using namespace pdf2htmlEX; @@ -343,12 +346,12 @@ void check_param() int main(int argc, char **argv) { // We need to adjust these directories before parsing the options. -#ifndef __MINGW32__ - param.tmp_dir = "/tmp"; - param.data_dir = PDF2HTMLEX_DATA_PATH; -#else +#if defined(__MINGW32__) param.data_dir = get_exec_dir(argv[0]); param.tmp_dir = get_tmp_dir(); +#else + param.tmp_dir = "/tmp"; + param.data_dir = PDF2HTMLEX_DATA_PATH; #endif parse_options(argc, argv); diff --git a/src/util/win32.cc b/src/util/mingw.cc similarity index 84% rename from src/util/win32.cc rename to src/util/mingw.cc index ee45511..5d75be0 100644 --- a/src/util/win32.cc +++ b/src/util/mingw.cc @@ -14,7 +14,7 @@ #include #include -#include "win32.h" +#include "mingw.h" using namespace std; @@ -55,12 +55,7 @@ string get_tmp_dir() tmp = getenv("TEMP"); } - if (tmp == nullptr) { - cerr << "Error: Cannot find temporary directory. Export TMP/TEMP variable."; - exit(EXIT_FAILURE); - } - - return std::string(tmp) + "/"; + return tmp != nullptr ? string(tmp) + "/" : "/"; } } // namespace pdf2htmlEX; diff --git a/src/util/win32.h b/src/util/mingw.h similarity index 86% rename from src/util/win32.h rename to src/util/mingw.h index a2e6dd0..f7a3b52 100644 --- a/src/util/win32.h +++ b/src/util/mingw.h @@ -5,8 +5,8 @@ * 2014.01.13 */ -#ifndef WIN32_H__ -#define WIN32_H__ +#ifndef MINGW_H__ +#define MINGW_H__ #ifdef __MINGW32__ @@ -24,5 +24,5 @@ namespace pdf2htmlEX { #endif //__MINGW32__ -#endif //WIN32_H__ +#endif //MINGW_H__ diff --git a/src/util/path.cc b/src/util/path.cc index 15e5200..4d451f6 100644 --- a/src/util/path.cc +++ b/src/util/path.cc @@ -11,7 +11,10 @@ #include #include "path.h" -#include "win32.h" + +#ifdef __MINGW32__ +#include "util/mingw.h" +#endif using std::string;