1 //
2 //	aegis - project change supervisor
3 //	Copyright (C) 1991-2006, 2008 Peter Miller
4 //
5 //	This program is free software; you can redistribute it and/or modify
6 //	it under the terms of the GNU General Public License as published by
7 //	the Free Software Foundation; either version 3 of the License, or
8 //	(at your option) any later version.
9 //
10 //	This program is distributed in the hope that it will be useful,
11 //	but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //	GNU General Public License for more details.
14 //
15 //	You should have received a copy of the GNU General Public License
16 //	along with this program; if not, see
17 //	<http://www.gnu.org/licenses/>.
18 //
19 
20 #include <common/ac/errno.h>
21 
22 #include <libaegis/glue.h>
23 #include <libaegis/os.h>
24 #include <libaegis/sub.h>
25 #include <common/trace.h>
26 
27 
28 void
os_rename(const nstring & a,const nstring & b)29 os_rename(const nstring &a, const nstring &b)
30 {
31     trace(("os_rename(a = \"%s\", b = \"%s\")\n{\n", a.c_str(), b.c_str()));
32     os_become_must_be_active();
33     if (glue_rename(a.c_str(), b.c_str()))
34     {
35 	int errno_old = errno;
36 	sub_context_ty *scp = sub_context_new();
37 	sub_errno_setx(scp, errno_old);
38 	sub_var_set_string(scp, "File_Name1", a);
39 	sub_var_set_string(scp, "File_Name2", b);
40 	fatal_intl(scp, i18n("rename(\"$filename1\", \"$filename2\"): $errno"));
41 	// NOTREACHED
42     }
43     trace(("}\n"));
44 }
45 
46 
47 void
os_rename(string_ty * a,string_ty * b)48 os_rename(string_ty *a, string_ty *b)
49 {
50     os_rename(nstring(a), nstring(b));
51 }
52