]> git.lyx.org Git - lyx.git/blobdiff - src/output.C
* GuiView.C (updateTab): do not update early if current tab has
[lyx.git] / src / output.C
index 11e96aee6a42a5818b0bafc307c59ff56c6d4e66..7b19e0b0911c2b2a9422b4e89d935f2f8a74d91f 100644 (file)
 
 #include "support/filetools.h"
 
-#include <fstream>
 
-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<typename OFStream>
+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