1 //
2 //      aegis - project change supervisor
3 //      Copyright (C) 1999, 2002-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/sys/types.h>
22 #include <common/ac/sys/stat.h>
23 
24 #include <libaegis/glue.h>
25 #include <libaegis/os.h>
26 #include <libaegis/sub.h>
27 #include <common/trace.h>
28 
29 
30 off_t
os_file_size(string_ty * path)31 os_file_size(string_ty *path)
32 {
33     trace(("os_mtime_actual(path = %p)\n{\n", path));
34     os_become_must_be_active();
35     trace_string(path->str_text);
36 
37     struct stat st;
38     int oret = glue_stat(path->str_text, &st);
39     if (oret)
40     {
41         int errno_old = errno;
42         sub_context_ty sc;
43         sc.errno_setx(errno_old);
44         sc.var_set_string("File_Name", path);
45         sc.fatal_intl(i18n("stat $filename: $errno"));
46         // NOTREACHED
47     }
48 
49     trace(("return %ld;\n", (long)st.st_size));
50     trace(("}\n"));
51     return st.st_size;
52 }
53 
54 
55 // vim: set ts=8 sw=4 et :
56