X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Foutput.C;h=7b19e0b0911c2b2a9422b4e89d935f2f8a74d91f;hb=e5a46922e916a06ad1b958d5895cc3cfb4f13d2c;hp=a5a3db5ecee40589be6da8f12bceec369ab4926c;hpb=8c93f63b48a1b15d4f3e163b7305213f2f73879e;p=lyx.git diff --git a/src/output.C b/src/output.C index a5a3db5ece..7b19e0b091 100644 --- a/src/output.C +++ b/src/output.C @@ -18,23 +18,45 @@ #include "support/filetools.h" -#include -using lyx::support::bformat; -using lyx::support::makeDisplayPath; +namespace lyx { + +using support::bformat; +using support::FileName; +using support::makeDisplayPath; using std::ofstream; using std::string; -bool openFileWrite(ofstream & ofs, string const & fname) +namespace { + +template +bool doOpenFileWrite(OFStream & ofs, FileName const & fname) { - ofs.open(fname.c_str()); + ofs.open(fname.toFilesystemEncoding().c_str()); if (!ofs) { - string const file = makeDisplayPath(fname, 50); - string text = bformat(_("Could not open the specified " - "document\n%1$s."), file); - Alert::error(_("Could not open file"), text); + 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); return false; } return true; } + +} + + +bool openFileWrite(ofstream & ofs, FileName const & fname) +{ + return doOpenFileWrite(ofs, fname); +} + + +bool openFileWrite(odocfstream & ofs, FileName const & fname) +{ + return doOpenFileWrite(ofs, fname); +} + + +} // namespace lyx