mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-07-05 17:48:38 +00:00
check all ofstream
This commit is contained in:
parent
475aff9897
commit
d2fb40fc00
|
@ -92,6 +92,8 @@ void HTMLRenderer::process(PDFDoc *doc)
|
||||||
{
|
{
|
||||||
auto page_fn = str_fmt("%s/%s%d.page", param->dest_dir.c_str(), param->output_filename.c_str(), i);
|
auto page_fn = str_fmt("%s/%s%d.page", param->dest_dir.c_str(), param->output_filename.c_str(), i);
|
||||||
html_fout.open((char*)page_fn, ofstream::binary);
|
html_fout.open((char*)page_fn, ofstream::binary);
|
||||||
|
if(!html_fout)
|
||||||
|
throw string("Cannot open ") + (char*)page_fn + " for writing";
|
||||||
fix_stream(html_fout);
|
fix_stream(html_fout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,6 +401,8 @@ void HTMLRenderer::pre_process()
|
||||||
|
|
||||||
css_path = (char*)fn,
|
css_path = (char*)fn,
|
||||||
css_fout.open(css_path, ofstream::binary);
|
css_fout.open(css_path, ofstream::binary);
|
||||||
|
if(!css_fout)
|
||||||
|
throw string("Cannot open ") + (char*)fn + " for writing";
|
||||||
fix_stream(css_fout);
|
fix_stream(css_fout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,6 +422,8 @@ void HTMLRenderer::pre_process()
|
||||||
|
|
||||||
html_path = (char*)fn;
|
html_path = (char*)fn;
|
||||||
html_fout.open(html_path, ofstream::binary);
|
html_fout.open(html_path, ofstream::binary);
|
||||||
|
if(!html_fout)
|
||||||
|
throw string("Cannot open ") + (char*)fn + " for writing";
|
||||||
fix_stream(html_fout);
|
fix_stream(html_fout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -432,11 +438,17 @@ void HTMLRenderer::post_process()
|
||||||
if(param->split_pages)
|
if(param->split_pages)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ofstream output((char*)str_fmt("%s/%s", param->dest_dir.c_str(), param->output_filename.c_str()));
|
ofstream output;
|
||||||
fix_stream(output);
|
{
|
||||||
|
auto fn = str_fmt("%s/%s", param->dest_dir.c_str(), param->output_filename.c_str());
|
||||||
|
output.open((char*)fn, ofstream::binary);
|
||||||
|
if(!output)
|
||||||
|
throw string("Cannot open ") + (char*)fn + " for writing";
|
||||||
|
fix_stream(output);
|
||||||
|
}
|
||||||
|
|
||||||
// apply manifest
|
// apply manifest
|
||||||
ifstream manifest_fin((char*)str_fmt("%s/%s", param->data_dir.c_str(), MANIFEST_FILENAME.c_str()));
|
ifstream manifest_fin((char*)str_fmt("%s/%s", param->data_dir.c_str(), MANIFEST_FILENAME.c_str()), ifstream::binary);
|
||||||
if(!manifest_fin)
|
if(!manifest_fin)
|
||||||
throw "Cannot open the manifest file";
|
throw "Cannot open the manifest file";
|
||||||
|
|
||||||
|
@ -538,7 +550,7 @@ void HTMLRenderer::embed_file(ostream & out, const string & path, const string &
|
||||||
{
|
{
|
||||||
ifstream fin(path, ifstream::binary);
|
ifstream fin(path, ifstream::binary);
|
||||||
if(!fin)
|
if(!fin)
|
||||||
throw string("Cannot open file for embedding: ") + path;
|
throw string("Cannot open file ") + path + " for embedding";
|
||||||
out << iter->second.first << endl
|
out << iter->second.first << endl
|
||||||
<< fin.rdbuf()
|
<< fin.rdbuf()
|
||||||
<< iter->second.second << endl;
|
<< iter->second.second << endl;
|
||||||
|
@ -554,7 +566,11 @@ void HTMLRenderer::embed_file(ostream & out, const string & path, const string &
|
||||||
ifstream fin(path, ifstream::binary);
|
ifstream fin(path, ifstream::binary);
|
||||||
if(!fin)
|
if(!fin)
|
||||||
throw string("Cannot copy file: ") + path;
|
throw string("Cannot copy file: ") + path;
|
||||||
ofstream(param->dest_dir + "/" + fn, ofstream::binary) << fin.rdbuf();
|
auto out_path = param->dest_dir + "/" + fn;
|
||||||
|
ofstream out(out_path, ofstream::binary);
|
||||||
|
if(!out)
|
||||||
|
throw string("Cannot open file ") + path + " for embedding";
|
||||||
|
out << fin.rdbuf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,8 @@ string HTMLRenderer::dump_embedded_font (GfxFont * font, long long fn_id)
|
||||||
add_tmp_file(filepath);
|
add_tmp_file(filepath);
|
||||||
|
|
||||||
ofstream outf(filepath, ofstream::binary);
|
ofstream outf(filepath, ofstream::binary);
|
||||||
|
if(!outf)
|
||||||
|
throw string("Cannot open file ") + filepath + " for writing";
|
||||||
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
int len;
|
int len;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user