1 //
2 //	aegis - project change supervisor
3 //	Copyright (C) 1999, 2003-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 <common/ac/sys/types.h>
23 #include <common/ac/sys/stat.h>
24 
25 #include <libaegis/glue.h>
26 #include <libaegis/os.h>
27 #include <libaegis/sub.h>
28 
29 
30 int
os_isa_special_file(string_ty * path)31 os_isa_special_file(string_ty *path)
32 {
33     struct stat	st;
34     int		err;
35 
36     os_become_must_be_active();
37     if (path->str_length == 0)
38 	return 1;
39 #ifdef S_IFLNK
40     err = glue_lstat(path->str_text, &st);
41 #else
42     err = glue_stat(path->str_text, &st);
43 #endif
44     if (err < 0)
45     {
46 	sub_context_ty  *scp;
47 	int             errno_old;
48 
49 	errno_old = errno;
50 	if (errno_old == ENOENT)
51 	    return 0;
52 	scp = sub_context_new();
53 	sub_errno_setx(scp, errno_old);
54 	sub_var_set_string(scp, "File_Name", path);
55 	fatal_intl(scp, i18n("stat $filename: $errno"));
56 	// NOTREACHED
57     }
58 
59     //
60     // This is used by aenf.
61     // By special, in this context, I mean not a regular file.
62     //
63     return !S_ISREG(st.st_mode);
64 }
65