diff --git a/src/buffer.C b/src/buffer.C index e087722523..e3e2ea27e5 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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) { diff --git a/src/buffer.h b/src/buffer.h index 6b6addc10b..f37336790b 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -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); /// diff --git a/src/bufferlist.C b/src/bufferlist.C index aa532e98b3..1d14c077d3 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -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); } diff --git a/src/exporter.C b/src/exporter.C index 0956e100d2..853e8b7db1 100644 --- a/src/exporter.C +++ b/src/exporter.C @@ -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; } diff --git a/src/graphics/PreviewLoader.C b/src/graphics/PreviewLoader.C index f964ca09fc..840914a971 100644 --- a/src/graphics/PreviewLoader.C +++ b/src/graphics/PreviewLoader.C @@ -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); diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 5cee1b1f15..c1fec50560 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -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, diff --git a/src/output.C b/src/output.C index ab1177b974..7b19e0b091 100644 --- a/src/output.C +++ b/src/output.C @@ -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 -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); } diff --git a/src/output.h b/src/output.h index b2294e6de6..fea5e1bb04 100644 --- a/src/output.h +++ b/src/output.h @@ -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 diff --git a/src/output_plaintext.C b/src/output_plaintext.C index de102dc40d..46e3990ce1 100644 --- a/src/output_plaintext.C +++ b/src/output_plaintext.C @@ -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; diff --git a/src/output_plaintext.h b/src/output_plaintext.h index 16eb1414f1..682a94794f 100644 --- a/src/output_plaintext.h +++ b/src/output_plaintext.h @@ -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 &); /// diff --git a/src/tex2lyx/tex2lyx.C b/src/tex2lyx/tex2lyx.C index 3ca623d1d2..8f618672bf 100644 --- a/src/tex2lyx/tex2lyx.C +++ b/src/tex2lyx/tex2lyx.C @@ -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;