X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Foutput.C;h=7b19e0b0911c2b2a9422b4e89d935f2f8a74d91f;hb=c727c6db7f2dd7f6a727462f5d11964888d0e76e;hp=11e96aee6a42a5818b0bafc307c59ff56c6d4e66;hpb=43b77ba2d722cdb8a9437926f839c1dcbf3c0b89;p=lyx.git diff --git a/src/output.C b/src/output.C index 11e96aee6a..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(lyx::to_utf8(_("Could not open the specified " - "document\n%1$s.")), file); - Alert::error(lyx::to_utf8(_("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