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)
|
include(CheckCXXCompilerFlag)
|
||||||
check_cxx_compiler_flag("${CMAKE_CXX_FLAGS}" CXX0X_SUPPORT)
|
check_cxx_compiler_flag("${CMAKE_CXX_FLAGS}" CXX0X_SUPPORT)
|
||||||
if(NOT 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()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ void HTMLRenderer::process(PDFDoc *doc)
|
|||||||
int page_count = (param.last_page - param.first_page + 1);
|
int page_count = (param.last_page - param.first_page + 1);
|
||||||
for(int i = param.first_page; i <= param.last_page ; ++i)
|
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";
|
cerr << "Stop processing, reach max size\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ struct Param
|
|||||||
int embed_javascript;
|
int embed_javascript;
|
||||||
int embed_outline;
|
int embed_outline;
|
||||||
int split_pages;
|
int split_pages;
|
||||||
int max_size;
|
int tmp_file_size_limit;
|
||||||
std::string dest_dir;
|
std::string dest_dir;
|
||||||
std::string css_filename;
|
std::string css_filename;
|
||||||
std::string page_filename;
|
std::string page_filename;
|
||||||
@ -70,14 +70,11 @@ struct Param
|
|||||||
// misc.
|
// misc.
|
||||||
int clean_tmp;
|
int clean_tmp;
|
||||||
std::string data_dir;
|
std::string data_dir;
|
||||||
std::string basetmp_dir;
|
std::string tmp_dir;
|
||||||
int css_draw;
|
int css_draw;
|
||||||
int debug;
|
int debug;
|
||||||
|
|
||||||
std::string input_filename, output_filename;
|
std::string input_filename, output_filename;
|
||||||
|
|
||||||
// not a paramater
|
|
||||||
std::string tmp_dir;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pdf2htmlEX
|
} // namespace pdf2htmlEX
|
||||||
|
@ -18,8 +18,11 @@ using namespace std;
|
|||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
# define STAT stat
|
# define STAT stat
|
||||||
|
# define RMDIR rmdir
|
||||||
#else
|
#else
|
||||||
|
# include <direct.h>
|
||||||
# define STAT _stat
|
# define STAT _stat
|
||||||
|
# define RMDIR _rmdir
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace pdf2htmlEX {
|
namespace pdf2htmlEX {
|
||||||
@ -56,7 +59,7 @@ void TmpFiles::clean()
|
|||||||
cerr << "Remove temporary file: " << fn << endl;
|
cerr << "Remove temporary file: " << fn << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(param.tmp_dir.c_str());
|
RMDIR(param.tmp_dir.c_str());
|
||||||
if(param.debug)
|
if(param.debug)
|
||||||
cerr << "Remove temporary directory: " << param.tmp_dir << endl;
|
cerr << "Remove temporary directory: " << param.tmp_dir << endl;
|
||||||
}
|
}
|
||||||
|
@ -114,11 +114,11 @@ void embed_parser (const char * str)
|
|||||||
|
|
||||||
void prepare_directories()
|
void prepare_directories()
|
||||||
{
|
{
|
||||||
std::string tmp_dir = param.basetmp_dir + "/pdf2htmlEX-XXXXXX";
|
std::string tmp_dir = param.tmp_dir + "/pdf2htmlEX-XXXXXX";
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
errno = 0;
|
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());
|
strcpy(pBuf.get(), tmp_dir.c_str());
|
||||||
auto p = mkdtemp(pBuf.get());
|
auto p = mkdtemp(pBuf.get());
|
||||||
if(p == nullptr)
|
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-image", ¶m.embed_image, 1, "embed image files into output")
|
||||||
.add("embed-javascript", ¶m.embed_javascript, 1, "embed JavaScript 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("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("split-pages", ¶m.split_pages, 0, "split pages into separate files")
|
||||||
.add("dest-dir", ¶m.dest_dir, ".", "specify destination directory")
|
.add("dest-dir", ¶m.dest_dir, ".", "specify destination directory")
|
||||||
.add("css-filename", ¶m.css_filename, "", "filename of the generated css file")
|
.add("css-filename", ¶m.css_filename, "", "filename of the generated css file")
|
||||||
@ -210,7 +210,7 @@ void parse_options (int argc, char **argv)
|
|||||||
|
|
||||||
// misc.
|
// misc.
|
||||||
.add("clean-tmp", ¶m.clean_tmp, 1, "remove temporary files after conversion")
|
.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")
|
.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
|
// 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")
|
// .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.
|
// We need to adjust these directories before parsing the options.
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
param.basetmp_dir = "/tmp";
|
param.tmp_dir = "/tmp";
|
||||||
param.data_dir = PDF2HTMLEX_DATA_PATH;
|
param.data_dir = PDF2HTMLEX_DATA_PATH;
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
@ -374,7 +374,7 @@ int main(int argc, char **argv)
|
|||||||
// Under Windows, the temp path is not under /tmp, find it.
|
// Under Windows, the temp path is not under /tmp, find it.
|
||||||
char temppath[MAX_PATH];
|
char temppath[MAX_PATH];
|
||||||
::GetTempPath(MAX_PATH, temppath);
|
::GetTempPath(MAX_PATH, temppath);
|
||||||
param.basetmp_dir = temppath;
|
param.tmp_dir = temppath;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user