more unicode filenames

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16173 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2006-12-04 15:46:57 +00:00
parent 534095ce9e
commit 9eab5fa88a
11 changed files with 39 additions and 33 deletions

View File

@ -829,7 +829,7 @@ bool Buffer::do_writeFile(ostream & ofs) const
}
bool Buffer::makeLaTeXFile(string const & fname,
bool Buffer::makeLaTeXFile(FileName const & fname,
string const & original_path,
OutputParams const & runparams,
bool output_preamble, bool output_body)
@ -1025,7 +1025,7 @@ bool Buffer::isDocBook() const
}
void Buffer::makeDocBookFile(string const & fname,
void Buffer::makeDocBookFile(FileName const & fname,
OutputParams const & runparams,
bool const body_only)
{
@ -1036,7 +1036,7 @@ void Buffer::makeDocBookFile(string const & fname,
if (!openFileWrite(ofs, fname))
return;
writeDocBookSource(ofs, fname, runparams, body_only);
writeDocBookSource(ofs, fname.absFilename(), runparams, body_only);
ofs.close();
if (ofs.fail())
@ -1124,7 +1124,7 @@ int Buffer::runChktex()
busy(true);
// get LaTeX-Filename
string const name = getLatexName();
string const name = getLatexName(false);
string const path = temppath();
string const org_path = filePath();
@ -1135,10 +1135,10 @@ int Buffer::runChktex()
OutputParams runparams;
runparams.flavor = OutputParams::LATEX;
runparams.nice = false;
makeLaTeXFile(name, org_path, runparams);
makeLaTeXFile(FileName(name), org_path, runparams);
TeXErrors terr;
Chktex chktex(lyxrc.chktex_command, name, filePath());
Chktex chktex(lyxrc.chktex_command, onlyFilename(name), filePath());
int const res = chktex.run(terr); // run chktex
if (res == -1) {

View File

@ -147,7 +147,7 @@ public:
bool writeFile(support::FileName const &) const;
/// Just a wrapper for the method below, first creating the ofstream.
bool makeLaTeXFile(std::string const & filename,
bool makeLaTeXFile(support::FileName const & filename,
std::string const & original_path,
OutputParams const &,
bool output_preamble = true,
@ -159,7 +159,7 @@ public:
bool output_preamble = true,
bool output_body = true);
///
void makeDocBookFile(std::string const & filename,
void makeDocBookFile(support::FileName const & filename,
OutputParams const & runparams_in,
bool only_body = false);
///

View File

@ -319,7 +319,7 @@ void BufferList::updateIncludedTeXfiles(string const & mastertmpdir,
string writefile = mastertmpdir;
writefile += '/';
writefile += (*it)->getLatexName();
(*it)->makeLaTeXFile(writefile, mastertmpdir,
(*it)->makeLaTeXFile(FileName(writefile), mastertmpdir,
runparams, false);
(*it)->markDepClean(mastertmpdir);
}

View File

@ -192,19 +192,19 @@ bool Exporter::Export(Buffer * buffer, string const & format,
// Ascii backend
if (backend_format == "text")
writeFileAscii(*buffer, filename, runparams);
writeFileAscii(*buffer, FileName(filename), runparams);
// no backend
else if (backend_format == "lyx")
buffer->writeFile(FileName(filename));
// Docbook backend
else if (buffer->isDocBook()) {
runparams.nice = !put_in_tempdir;
buffer->makeDocBookFile(filename, runparams);
buffer->makeDocBookFile(FileName(filename), runparams);
}
// LaTeX backend
else if (backend_format == format) {
runparams.nice = true;
if (!buffer->makeLaTeXFile(filename, string(), runparams))
if (!buffer->makeLaTeXFile(FileName(filename), string(), runparams))
return false;
} else if (!lyxrc.tex_allows_spaces
&& contains(buffer->filePath(), ' ')) {
@ -213,7 +213,7 @@ bool Exporter::Export(Buffer * buffer, string const & format,
return false;
} else {
runparams.nice = false;
if (!buffer->makeLaTeXFile(filename, buffer->filePath(), runparams))
if (!buffer->makeLaTeXFile(FileName(filename), buffer->filePath(), runparams))
return false;
}

View File

@ -568,12 +568,12 @@ void PreviewLoader::Impl::startLoading()
pending_.clear();
// Output the LaTeX file.
string const latexfile = filename_base + ".tex";
FileName const latexfile(filename_base + ".tex");
// FIXME UNICODE
// This creates an utf8 encoded file, but the proper inputenc
// command is missing.
odocfstream of(latexfile.c_str());
odocfstream of(latexfile.toFilesystemEncoding().c_str());
if (!of) {
lyxerr[Debug::GRAPHICS] << "PreviewLoader::startLoading()\n"
<< "Unable to create LaTeX file\n"
@ -590,7 +590,7 @@ void PreviewLoader::Impl::startLoading()
// The conversion command.
ostringstream cs;
cs << pconverter_->command << ' ' << pconverter_->to << ' '
<< support::quoteName(latexfile) << ' '
<< support::quoteName(latexfile.toFilesystemEncoding()) << ' '
<< int(font_scaling_factor_) << ' '
<< theApp()->hexName(LColor::preview) << ' '
<< theApp()->hexName(LColor::background);

View File

@ -428,7 +428,7 @@ int InsetInclude::latex(Buffer const & buffer, odocstream & os,
// argument. Should we set it to string(), or should makeLaTeXFile
// make use of it somehow? (JMarc 20031002)
#endif
tmp->makeLaTeXFile(writefile.absFilename(),
tmp->makeLaTeXFile(writefile,
onlyPath(masterFilename(buffer)),
runparams, false);
} else {
@ -535,7 +535,7 @@ int InsetInclude::docbook(Buffer const & buffer, odocstream & os,
lyxerr[Debug::LATEX] << "exportfile:" << exportfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
tmp->makeDocBookFile(writefile.absFilename(), runparams, true);
tmp->makeDocBookFile(writefile, runparams, true);
}
runparams.exportdata->addExternalFile("docbook", writefile,

View File

@ -22,6 +22,7 @@
namespace lyx {
using support::bformat;
using support::FileName;
using support::makeDisplayPath;
using std::ofstream;
@ -30,11 +31,11 @@ using std::string;
namespace {
template<typename OFStream>
bool doOpenFileWrite(OFStream & ofs, string const & fname)
bool doOpenFileWrite(OFStream & ofs, FileName const & fname)
{
ofs.open(fname.c_str());
ofs.open(fname.toFilesystemEncoding().c_str());
if (!ofs) {
docstring const file = makeDisplayPath(fname, 50);
docstring const file = makeDisplayPath(fname.absFilename(), 50);
docstring text = bformat(_("Could not open the specified "
"document\n%1$s."), file);
frontend::Alert::error(_("Could not open file"), text);
@ -46,13 +47,13 @@ bool doOpenFileWrite(OFStream & ofs, string const & fname)
}
bool openFileWrite(ofstream & ofs, string const & fname)
bool openFileWrite(ofstream & ofs, FileName const & fname)
{
return doOpenFileWrite(ofs, fname);
}
bool openFileWrite(odocfstream & ofs, string const & fname)
bool openFileWrite(odocfstream & ofs, FileName const & fname)
{
return doOpenFileWrite(ofs, fname);
}

View File

@ -17,8 +17,10 @@
namespace lyx {
bool openFileWrite(std::ofstream & ofs, std::string const & fname);
bool openFileWrite(odocfstream & ofs, std::string const & fname);
namespace support { class FileName; }
bool openFileWrite(std::ofstream & ofs, support::FileName const & fname);
bool openFileWrite(odocfstream & ofs, support::FileName const & fname);
} // namespace lyx

View File

@ -22,6 +22,7 @@
#include "ParagraphList.h"
#include "ParagraphParameters.h"
#include "support/filename.h"
#include "support/lstrings.h"
@ -31,6 +32,7 @@ using support::ascii_lowercase;
using support::compare_ascii_no_case;
using support::compare_no_case;
using support::contains;
using support::FileName;
using std::endl;
using std::ostream;
@ -38,7 +40,7 @@ using std::pair;
using std::string;
void writeFileAscii(Buffer const & buf, string const & fname,
void writeFileAscii(Buffer const & buf, FileName const & fname,
OutputParams const & runparams)
{
odocfstream ofs;

View File

@ -17,13 +17,15 @@
namespace lyx {
namespace support { class FileName; }
class Buffer;
class OutputParams;
class Paragraph;
///
void writeFileAscii(Buffer const & buf, std::string const &,
void writeFileAscii(Buffer const & buf, support::FileName const &,
OutputParams const &);
///

View File

@ -456,17 +456,16 @@ void tex2lyx(std::istream &is, std::ostream &os)
/// convert TeX from \p infilename to LyX and write it to \p os
bool tex2lyx(string const &infilename, std::ostream &os)
bool tex2lyx(FileName const & infilename, std::ostream &os)
{
BOOST_ASSERT(lyx::support::absolutePath(infilename));
ifstream is(infilename.c_str());
ifstream is(infilename.toFilesystemEncoding().c_str());
if (!is.good()) {
cerr << "Could not open input file \"" << infilename
<< "\" for reading." << endl;
return false;
}
string const oldParentFilePath = parentFilePath;
parentFilePath = onlyPath(infilename);
parentFilePath = onlyPath(infilename.absFilename());
tex2lyx(is, os);
parentFilePath = oldParentFilePath;
return true;
@ -499,7 +498,7 @@ bool tex2lyx(string const &infilename, FileName const &outfilename)
cerr << "Input file: " << infilename << "\n";
cerr << "Output file: " << outfilename << "\n";
#endif
return tex2lyx(infilename, os);
return tex2lyx(FileName(infilename), os);
}
} // namespace lyx
@ -546,7 +545,7 @@ int main(int argc, char * argv[])
parentFilePath = masterFilePath;
if (outfilename == "-") {
if (tex2lyx(infilename, cout))
if (tex2lyx(FileName(infilename), cout))
return EXIT_SUCCESS;
else
return EXIT_FAILURE;