1 //
2 //      aegis - project change supervisor
3 //      Copyright (C) 1991-2006, 2008, 2012 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 #include <common/ac/stddef.h>
22 #include <common/ac/sys/types.h>
23 #include <utime.h>
24 
25 #include <libaegis/glue.h>
26 #include <libaegis/os.h>
27 #include <libaegis/sub.h>
28 #include <common/trace.h>
29 
30 
31 void
os_mtime_set(string_ty * path,time_t when)32 os_mtime_set(string_ty *path, time_t when)
33 {
34     struct utimbuf  utb;
35     int             err;
36 
37     trace(("os_mtime_set(path = %p, when = %ld)\n{\n", path, (long)when));
38     os_become_must_be_active();
39     trace_string(path->str_text);
40     trace(("when = %s", ctime(&when)));
41     utb.actime = when;
42     utb.modtime = when;
43     err = glue_utime(path->str_text, &utb);
44 #ifdef __CYGWIN__
45     if (err && errno == EACCES)
46         err = 0;
47 #endif
48     if (err)
49     {
50         sub_context_ty  *scp;
51         int             errno_old;
52 
53         errno_old = errno;
54         scp = sub_context_new();
55         sub_errno_setx(scp, errno_old);
56         sub_var_set_string(scp, "File_Name", path);
57         fatal_intl(scp, i18n("utime $filename: $errno"));
58         // NOTREACHED
59     }
60     trace(("}\n"));
61 }
62 
63 
64 // vim: set ts=8 sw=4 et :
65