1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-07-04 17:18:40 +00:00

Modifications following code review

Fixed rmdir under Windows/MINGW
This commit is contained in:
Marc Sanfacon 2014-01-09 08:14:12 -05:00
parent 652b40971a
commit 5fab160e05
5 changed files with 14 additions and 14 deletions

View File

@ -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()

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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", &param.embed_image, 1, "embed image files into output")
.add("embed-javascript", &param.embed_javascript, 1, "embed JavaScript files into output")
.add("embed-outline", &param.embed_outline, 1, "embed outlines into output")
.add("tmp-file-size-limit", &param.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", &param.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", &param.split_pages, 0, "split pages into separate files")
.add("dest-dir", &param.dest_dir, ".", "specify destination directory")
.add("css-filename", &param.css_filename, "", "filename of the generated css file")
@ -210,7 +210,7 @@ void parse_options (int argc, char **argv)
// misc.
.add("clean-tmp", &param.clean_tmp, 1, "remove temporary files after conversion")
.add("tmp-dir", &param.basetmp_dir, param.basetmp_dir, "specify the location of tempory directory.")
.add("tmp-dir", &param.tmp_dir, param.tmp_dir, "specify the location of tempory directory.")
.add("data-dir", &param.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", &param.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