mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-21 20:50:07 +00:00
Modifications following code review
Fixed rmdir under Windows/MINGW
This commit is contained in:
parent
652b40971a
commit
5fab160e05
@ -158,7 +158,7 @@ endif()
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag("${CMAKE_CXX_FLAGS}" CXX0X_SUPPORT)
|
||||
if(NOT CXX0X_SUPPORT)
|
||||
message(FATAL_ERROR "Error: you compiler does not support C++0x, please update it.")
|
||||
message(FATAL_ERROR "Error: your compiler does not support C++0x, please update it.")
|
||||
endif()
|
||||
|
||||
|
||||
|
@ -109,7 +109,7 @@ void HTMLRenderer::process(PDFDoc *doc)
|
||||
int page_count = (param.last_page - param.first_page + 1);
|
||||
for(int i = param.first_page; i <= param.last_page ; ++i)
|
||||
{
|
||||
if (param.max_size != -1 && tmp_files.get_total_size() > param.max_size * 1024) {
|
||||
if (param.tmp_file_size_limit != -1 && tmp_files.get_total_size() > param.tmp_file_size_limit * 1024) {
|
||||
cerr << "Stop processing, reach max size\n";
|
||||
break;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ struct Param
|
||||
int embed_javascript;
|
||||
int embed_outline;
|
||||
int split_pages;
|
||||
int max_size;
|
||||
int tmp_file_size_limit;
|
||||
std::string dest_dir;
|
||||
std::string css_filename;
|
||||
std::string page_filename;
|
||||
@ -70,14 +70,11 @@ struct Param
|
||||
// misc.
|
||||
int clean_tmp;
|
||||
std::string data_dir;
|
||||
std::string basetmp_dir;
|
||||
std::string tmp_dir;
|
||||
int css_draw;
|
||||
int debug;
|
||||
|
||||
std::string input_filename, output_filename;
|
||||
|
||||
// not a paramater
|
||||
std::string tmp_dir;
|
||||
};
|
||||
|
||||
} // namespace pdf2htmlEX
|
||||
|
@ -18,8 +18,11 @@ using namespace std;
|
||||
|
||||
#ifndef _WIN32
|
||||
# define STAT stat
|
||||
# define RMDIR rmdir
|
||||
#else
|
||||
# include <direct.h>
|
||||
# define STAT _stat
|
||||
# define RMDIR _rmdir
|
||||
#endif
|
||||
|
||||
namespace pdf2htmlEX {
|
||||
@ -56,7 +59,7 @@ void TmpFiles::clean()
|
||||
cerr << "Remove temporary file: " << fn << endl;
|
||||
}
|
||||
|
||||
remove(param.tmp_dir.c_str());
|
||||
RMDIR(param.tmp_dir.c_str());
|
||||
if(param.debug)
|
||||
cerr << "Remove temporary directory: " << param.tmp_dir << endl;
|
||||
}
|
||||
|
@ -114,11 +114,11 @@ void embed_parser (const char * str)
|
||||
|
||||
void prepare_directories()
|
||||
{
|
||||
std::string tmp_dir = param.basetmp_dir + "/pdf2htmlEX-XXXXXX";
|
||||
std::string tmp_dir = param.tmp_dir + "/pdf2htmlEX-XXXXXX";
|
||||
#ifndef _WIN32
|
||||
errno = 0;
|
||||
|
||||
auto_ptr<char> pBuf(new char[tmp_dir.size() + 1]);
|
||||
unique_ptr<char> pBuf(new char[tmp_dir.size() + 1]);
|
||||
strcpy(pBuf.get(), tmp_dir.c_str());
|
||||
auto p = mkdtemp(pBuf.get());
|
||||
if(p == nullptr)
|
||||
@ -169,7 +169,7 @@ void parse_options (int argc, char **argv)
|
||||
.add("embed-image", ¶m.embed_image, 1, "embed image files into output")
|
||||
.add("embed-javascript", ¶m.embed_javascript, 1, "embed JavaScript files into output")
|
||||
.add("embed-outline", ¶m.embed_outline, 1, "embed outlines into output")
|
||||
.add("tmp-file-size-limit", ¶m.max_size, -1, "Limit the temporary file output size, in KB (-1 for no limit). This is only an estimate, the output may be bigger")
|
||||
.add("tmp-file-size-limit", ¶m.tmp_file_size_limit, -1, "Limit the temporary file output size, in KB (-1 for no limit). This is only an estimate, the output may be bigger")
|
||||
.add("split-pages", ¶m.split_pages, 0, "split pages into separate files")
|
||||
.add("dest-dir", ¶m.dest_dir, ".", "specify destination directory")
|
||||
.add("css-filename", ¶m.css_filename, "", "filename of the generated css file")
|
||||
@ -210,7 +210,7 @@ void parse_options (int argc, char **argv)
|
||||
|
||||
// misc.
|
||||
.add("clean-tmp", ¶m.clean_tmp, 1, "remove temporary files after conversion")
|
||||
.add("tmp-dir", ¶m.basetmp_dir, param.basetmp_dir, "specify the location of tempory directory.")
|
||||
.add("tmp-dir", ¶m.tmp_dir, param.tmp_dir, "specify the location of tempory directory.")
|
||||
.add("data-dir", ¶m.data_dir, param.data_dir, "specify data directory")
|
||||
// TODO: css drawings are hidden on print, for annot links, need to fix it for other drawings
|
||||
// .add("css-draw", ¶m.css_draw, 0, "[experimental and unsupported] CSS drawing")
|
||||
@ -362,7 +362,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
// We need to adjust these directories before parsing the options.
|
||||
#ifndef _WIN32
|
||||
param.basetmp_dir = "/tmp";
|
||||
param.tmp_dir = "/tmp";
|
||||
param.data_dir = PDF2HTMLEX_DATA_PATH;
|
||||
#else
|
||||
{
|
||||
@ -374,7 +374,7 @@ int main(int argc, char **argv)
|
||||
// Under Windows, the temp path is not under /tmp, find it.
|
||||
char temppath[MAX_PATH];
|
||||
::GetTempPath(MAX_PATH, temppath);
|
||||
param.basetmp_dir = temppath;
|
||||
param.tmp_dir = temppath;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user