Unify the handling of converters that specify the resultfile= flag.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39985 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Julien Rioux 2011-10-25 23:31:36 +00:00
parent 5ddd2174d5
commit 665405da0a
2 changed files with 12 additions and 3 deletions

View File

@ -355,7 +355,7 @@ bool Converters::convert(Buffer const * buffer,
<< conv.from << " to " << conv.to);
}
infile = outfile;
outfile = FileName(conv.result_dir.empty()
outfile = FileName(conv.result_file.empty()
? changeExtension(from_file.absFileName(), conv.To->extension())
: addName(subst(conv.result_dir,
token_base, from_base),
@ -365,6 +365,9 @@ bool Converters::convert(Buffer const * buffer,
// if input and output files are equal, we use a
// temporary file as intermediary (JMarc)
FileName real_outfile;
if (!conv.result_file.empty())
real_outfile = FileName(changeExtension(from_file.absFileName(),
conv.To->extension()));
if (outfile == infile) {
real_outfile = infile;
// when importing, a buffer does not necessarily exist

View File

@ -250,7 +250,8 @@ static void build_conversion_command(string const & command, ostream & script)
" sys.exit(1)\n\n";
// Delete the infile
script << "unlinkNoThrow(infile)\n\n";
script << "if infile != outfile:\n"
" unlinkNoThrow(infile)\n\n";
}
@ -348,7 +349,12 @@ static void build_script(string const & from_file,
// Build the conversion command
string const infile = outfile;
string const infile_base = changeExtension(infile, string());
outfile = addExtension(to_base, conv.To->extension());
outfile = conv.result_file.empty()
? addExtension(to_base, conv.To->extension())
: addName(subst(conv.result_dir,
token_base, infile_base),
subst(conv.result_file,
token_base, onlyFileName(infile_base)));
// Store these names in the python script
script << "infile = "