diff --git a/CMakeLists.txt b/CMakeLists.txt index 73842eb..48b1822 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,6 +130,9 @@ else() set(PDF2HTMLEX_LIBS ${PDF2HTMLEX_LIBS} ${PYTHON_LIBRARIES}) endif() +# Add additional dependencies +set(PDF2HTMLEX_LIBS ${PDF2HTMLEX_LIBS} intl iconv gettextlib gettextpo gutils png jpeg openjpeg glib-2.0.dll z xml2 tiff gio-2.0.dll ltdl plibc.dll) + # debug build flags (overwrite default cmake debug flags) set(CMAKE_C_FLAGS_DEBUG "-ggdb -pg") diff --git a/src/pdf2htmlEX.cc b/src/pdf2htmlEX.cc index 7da4150..554915a 100644 --- a/src/pdf2htmlEX.cc +++ b/src/pdf2htmlEX.cc @@ -42,6 +42,31 @@ using namespace pdf2htmlEX; Param param; ArgParser argparser; +#if defined(_WIN32) +#include +char *mkdtemp(char *tempbuf) { + int rand_value = 0; + char* tempbase = NULL; + char tempbasebuf[MAX_PATH] = ""; + + if (strcmp(&tempbuf[strlen(tempbuf)-6], "XXXXXX")) { + errno = EINVAL; + return NULL; + } + + srand((unsigned)time(0)); + rand_value = (int)((rand() / ((double)RAND_MAX+1.0)) * 1e6); + tempbase = strrchr(tempbuf, '/'); + tempbase = tempbase ? tempbase+1 : tempbuf; + strcpy(tempbasebuf, tempbase); + sprintf(&tempbasebuf[strlen(tempbasebuf)-6], "%d", rand_value); + ::GetTempPath(MAX_PATH, tempbuf); + strcat(tempbuf, tempbasebuf); + ::CreateDirectory(tempbuf, NULL); + return tempbuf; +} +#endif + void deprecated_font_suffix(const char * dummy = nullptr) { cerr << "--font-suffix is deprecated. Use `--font-format` instead." << endl; diff --git a/src/util/ffw.c b/src/util/ffw.c index 01228df..ebbd258 100644 --- a/src/util/ffw.c +++ b/src/util/ffw.c @@ -19,6 +19,11 @@ #include "ffw.h" +#if defined(_WIN32) +#undef printf +#undef vfprintf +#endif + static real EPS=1e-6; static inline int min(int a, int b) diff --git a/src/util/path.cc b/src/util/path.cc index c928454..8815691 100644 --- a/src/util/path.cc +++ b/src/util/path.cc @@ -14,6 +14,17 @@ using std::string; +#if defined(_WIN32) +#include +int mkdir(const char *pathname, mode_t mode) { + if (::GetFileAttributes(pathname) == FILE_ATTRIBUTE_DIRECTORY) { + errno = EEXIST; + return -1; + } + return ::CreateDirectory(pathname, NULL) ? 0 : -1; +} +#endif + namespace pdf2htmlEX { void create_directories(const string & path) @@ -31,9 +42,15 @@ void create_directories(const string & path) { if(errno == EEXIST) { +#if defined(_WIN32) + struct _stat32 stat_buf; + if((_stat32(path.c_str(), &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) + return; +#else struct stat stat_buf; if((stat(path.c_str(), &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) return; +#endif } throw string("Cannot create directory: ") + path;