]> git.lyx.org Git - lyx.git/blob - src/support/rename.C
* lyxfunctional.h: delete compare_memfun and helper classes
[lyx.git] / src / support / rename.C
1 /**
2  * \file rename.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 <cstdio>
14
15 #include "support/lyxlib.h"
16
17
18 using std::string;
19
20
21 bool lyx::support::rename(string const & from, string const & to)
22 {
23 #ifdef __EMX__
24         unlink(to);
25 #endif
26         if (::rename(from.c_str(), to.c_str()) == -1)
27                 if (copy(from, to)) {
28                         unlink(from);
29                         return true;
30                 } else
31                         return false;
32         return true;
33 }