]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlVCLog.C
0e13c4bae3b4b111d20aee7ccb5c61b4b0535254
[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 <config.h>
16
17 #ifdef __GNUG__
18 #pragma implementation
19 #endif
20
21 #include "ControlVCLog.h"
22 #include "Lsstream.h"
23 #include "ButtonControllerBase.h"
24 #include "buffer.h"
25 #include "lyxrc.h"
26 #include "gettext.h"
27
28
29 #include "support/lyxlib.h"
30
31 #include <fstream>
32
33 using std::endl;
34
35
36 ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
37         : ControlDialogBD(lv, d)
38 {}
39
40
41 string const ControlVCLog::getBufferFileName() const
42 {
43         return buffer()->fileName();
44 }
45
46
47 stringstream & ControlVCLog::getVCLogFile(stringstream & ss) const
48 {
49         string const name = buffer()->lyxvc.getLogFile();
50
51         std::ifstream in(name.c_str());
52
53         bool found = (in.get());
54
55         if (found) {
56                 in.seekg(0, std::ios::beg); // rewind to the beginning
57
58                 ss << in.rdbuf();
59                 found = ss.good();
60         }
61
62         if (!found)
63                 ss << _("No version control log file found.") << endl;
64
65         lyx::unlink(name);
66
67         return ss;
68 }