]> git.lyx.org Git - lyx.git/blob - src/output.C
Revert change in rev. 15955 because as Georg says:
[lyx.git] / src / output.C
1 /**
2  * \file output.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "output.h"
14
15 #include "gettext.h"
16
17 #include "frontends/Alert.h"
18
19 #include "support/filetools.h"
20
21
22 namespace lyx {
23
24 using support::bformat;
25 using support::makeDisplayPath;
26
27 using std::ofstream;
28 using std::string;
29
30 namespace {
31
32 template<typename OFStream>
33 bool doOpenFileWrite(OFStream & ofs, string const & fname)
34 {
35         ofs.open(fname.c_str());
36         if (!ofs) {
37                 docstring const file = makeDisplayPath(fname, 50);
38                 docstring text = bformat(_("Could not open the specified "
39                                                      "document\n%1$s."), file);
40                 frontend::Alert::error(_("Could not open file"), text);
41                 return false;
42         }
43         return true;
44 }
45
46 }
47
48
49 bool openFileWrite(ofstream & ofs, string const & fname)
50 {
51         return doOpenFileWrite(ofs, fname);
52 }
53
54
55 bool openFileWrite(odocfstream & ofs, string const & fname)
56 {
57         return doOpenFileWrite(ofs, fname);
58 }
59
60
61 } // namespace lyx