]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlVCLog.C
move more support functions into namespace lyx, small other changes
[lyx.git] / src / frontends / controllers / ControlVCLog.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2001 The LyX Team.
7  *
8  * ======================================================
9  *
10  * \file ControlVCLog.C
11  * \author John Levon, moz@compsoc.man.ac.uk
12  * \author Angus Leeming <a.leeming@ic.ac.uk>
13  */
14
15 #include <fstream>
16
17 #ifdef __GNUG__
18 #pragma implementation
19 #endif
20
21 #include <config.h>
22 #include "Lsstream.h"
23 #include "ControlVCLog.h"
24 #include "buffer.h"
25 #include "LyXView.h"
26 #include "Dialogs.h"
27 #include "lyxrc.h"
28
29 using SigC::slot;
30 using std::endl;
31
32 ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
33         : ControlDialog<ControlConnectBD>(lv, d)
34 {
35         d_.showVCLogFile.connect(slot(this, &ControlVCLog::show));
36 }
37
38 string const ControlVCLog::getBufferFileName() const
39 {
40         return lv_.view()->buffer()->fileName();
41 }
42
43
44 std::stringstream & ControlVCLog::getVCLogFile(std::stringstream & ss) const
45 {
46         string const name = lv_.view()->buffer()->lyxvc.getLogFile();
47
48         std::ifstream in(name.c_str());
49
50         bool found = (in.get());
51
52         if (found) {
53                 in.seekg(0, std::ios::beg); // rewind to the beginning
54
55                 ss << in.rdbuf();
56                 found = ss.good();
57         }
58         
59         if (!found)
60                 ss << "No version control log file found." << endl;
61
62         lyx::unlink(name);
63
64         return ss;
65 }