2003-11-05 12:06:20 +00:00
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file output.cpp
|
2003-11-05 12:06:20 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "output.h"
|
|
|
|
|
|
|
|
|
|
#include "gettext.h"
|
|
|
|
|
|
2007-04-28 20:44:46 +00:00
|
|
|
|
#include "frontends/alert.h"
|
2003-11-05 12:06:20 +00:00
|
|
|
|
|
|
|
|
|
#include "support/filetools.h"
|
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
using support::bformat;
|
2006-12-04 15:46:57 +00:00
|
|
|
|
using support::FileName;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
using support::makeDisplayPath;
|
2006-09-11 08:54:10 +00:00
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
|
using std::ofstream;
|
|
|
|
|
using std::string;
|
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
template<typename OFStream>
|
2006-12-04 15:46:57 +00:00
|
|
|
|
bool doOpenFileWrite(OFStream & ofs, FileName const & fname)
|
2003-11-05 12:06:20 +00:00
|
|
|
|
{
|
2006-12-04 15:46:57 +00:00
|
|
|
|
ofs.open(fname.toFilesystemEncoding().c_str());
|
2003-11-05 12:06:20 +00:00
|
|
|
|
if (!ofs) {
|
2006-12-04 15:46:57 +00:00
|
|
|
|
docstring const file = makeDisplayPath(fname.absFilename(), 50);
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring text = bformat(_("Could not open the specified "
|
|
|
|
|
"document\n%1$s."), file);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
frontend::Alert::error(_("Could not open file"), text);
|
2003-11-05 12:06:20 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2006-10-11 19:40:50 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-12-04 15:46:57 +00:00
|
|
|
|
bool openFileWrite(ofstream & ofs, FileName const & fname)
|
2006-10-11 19:40:50 +00:00
|
|
|
|
{
|
|
|
|
|
return doOpenFileWrite(ofs, fname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-12-04 15:46:57 +00:00
|
|
|
|
bool openFileWrite(odocfstream & ofs, FileName const & fname)
|
2006-10-11 19:40:50 +00:00
|
|
|
|
{
|
|
|
|
|
return doOpenFileWrite(ofs, fname);
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|