mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
Make it work on MingW
This commit is contained in:
parent
166efc3892
commit
5aebf2c738
@ -206,6 +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/ArgParser.h
|
||||
src/ArgParser.cc
|
||||
src/Base64Stream.h
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "TmpFiles.h"
|
||||
#include "Param.h"
|
||||
#include "util/win32.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include "util/path.h"
|
||||
#include "util/ffw.h"
|
||||
#include "util/win32.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace pdf2htmlEX;
|
||||
@ -342,8 +343,13 @@ void check_param()
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// We need to adjust these directories before parsing the options.
|
||||
#ifndef _WIN32
|
||||
param.tmp_dir = "/tmp";
|
||||
param.data_dir = PDF2HTMLEX_DATA_PATH;
|
||||
#else
|
||||
param.data_dir = get_data_dir(argv[0]);
|
||||
param.tmp_dir = get_tmp_dir();
|
||||
#endif
|
||||
|
||||
parse_options(argc, argv);
|
||||
check_param();
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#include "path.h"
|
||||
#include "win32.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
|
57
src/util/win32.cc
Normal file
57
src/util/win32.cc
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Win32 specific functions
|
||||
*
|
||||
* by MarcSanfacon
|
||||
* 2014.01.13
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <time.h>
|
||||
#include <sstream>
|
||||
#include <windows.h>
|
||||
|
||||
#include "win32.h"
|
||||
|
||||
char* mkdtemp(char* temp)
|
||||
{
|
||||
if (temp != nullptr) {
|
||||
bool created = false;
|
||||
char value[30];
|
||||
|
||||
srand((unsigned)time(0));
|
||||
while (!created) {
|
||||
int rand_value = (int)((rand() / ((double)RAND_MAX+1.0)) * 1e6);
|
||||
sprintf(value, "%06d", rand_value);
|
||||
sprintf(temp + strlen(temp) - 6, "%6.6s", value);
|
||||
created = _mkdir(temp) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
namespace pdf2htmlEX {
|
||||
std::string get_data_dir(char *dir)
|
||||
{
|
||||
// Under Windows, the default data_dir is under /data in the pdf2htmlEX directory
|
||||
std::stringstream ss;
|
||||
ss << dirname(dir) << "/data";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string get_tmp_dir()
|
||||
{
|
||||
// Under Windows, the temp path is not under /tmp, find it.
|
||||
char temppath[MAX_PATH];
|
||||
::GetTempPath(MAX_PATH, temppath);
|
||||
return temppath;
|
||||
}
|
||||
|
||||
} // namespace pdf2htmlEX;
|
||||
|
||||
#endif //_WIN32
|
||||
|
30
src/util/win32.h
Normal file
30
src/util/win32.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Win32 specific functions
|
||||
*
|
||||
* by MarcSanfacon
|
||||
* 2014.01.13
|
||||
*/
|
||||
|
||||
#ifndef WIN32_H__
|
||||
#define WIN32_H__
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <io.h>
|
||||
#include <libgen.h>
|
||||
#include <sstream>
|
||||
|
||||
char *mkdtemp(char *temp);
|
||||
|
||||
#define mkdir(A, B) _mkdir(A)
|
||||
#define stat _stat
|
||||
|
||||
namespace pdf2htmlEX {
|
||||
std::string get_data_dir(char *dir);
|
||||
std::string get_tmp_dir();
|
||||
} // namespace pdf2htmlEX
|
||||
|
||||
#endif //_WIN32
|
||||
|
||||
#endif //WIN32_H__
|
||||
|
Loading…
Reference in New Issue
Block a user