2003-06-18 09:56:10 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file rename.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
2003-07-28 22:37:28 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2003-06-18 09:56:10 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-06-18 09:56:10 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2000-09-05 13:16:19 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "support/lyxlib.h"
|
|
|
|
|
|
2004-11-07 13:22:51 +00:00
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
|
bool lyx::support::rename(string const & from, string const & to)
|
2000-09-26 13:54:57 +00:00
|
|
|
|
{
|
2000-11-06 11:20:22 +00:00
|
|
|
|
if (::rename(from.c_str(), to.c_str()) == -1)
|
2003-06-30 23:56:22 +00:00
|
|
|
|
if (copy(from, to)) {
|
|
|
|
|
unlink(from);
|
2000-11-13 10:35:02 +00:00
|
|
|
|
return true;
|
|
|
|
|
} else
|
|
|
|
|
return false;
|
2000-11-06 11:20:22 +00:00
|
|
|
|
return true;
|
2000-09-26 13:54:57 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|