]> git.lyx.org Git - lyx.git/blob - src/support/copy.C
If I ever see another licence blurb again, it'll be too soon...
[lyx.git] / src / support / copy.C
1 /**
2  * \file copy.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 <fstream>
14
15 #include "support/lyxlib.h"
16 #include "LString.h"
17
18 using std::ifstream;
19 using std::ofstream;
20 using std::ios;
21
22 bool lyx::support::copy(string const & from, string const & to)
23 {
24         ifstream ifs(from.c_str());
25         if (!ifs)
26                 return false;
27         ofstream ofs(to.c_str(),
28                      ios::binary | ios::out | ios::trunc);
29         if (!ofs)
30                 return false;
31         ofs << ifs.rdbuf();
32         if (ofs.good())
33                 return true;
34         return false;
35 }