lyx_mirror/src/frontends/controllers/ControlVCLog.C

66 lines
1.3 KiB
C++
Raw Normal View History

/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
*
* ======================================================
*
* \file ControlVCLog.C
* \author John Levon, moz@compsoc.man.ac.uk
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#include <fstream>
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "Lsstream.h"
#include "ControlVCLog.h"
#include "buffer.h"
#include "LyXView.h"
#include "Dialogs.h"
#include "lyxrc.h"
using SigC::slot;
using std::endl;
ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
: ControlDialog<ControlConnectBD>(lv, d)
{
d_.showVCLogFile.connect(slot(this, &ControlVCLog::show));
}
string const ControlVCLog::getBufferFileName() const
{
return lv_.view()->buffer()->fileName();
}
std::stringstream & ControlVCLog::getVCLogFile(std::stringstream & ss) const
{
string const name = lv_.view()->buffer()->lyxvc.getLogFile();
std::ifstream in(name.c_str());
bool found = (in.get());
if (found) {
in.seekg(0, std::ios::beg); // rewind to the beginning
ss << in.rdbuf();
found = ss.good();
}
if (!found)
ss << "No version control log file found." << endl;
lyx::unlink(name);
return ss;
}