Mercurial > hg > octave-kai > gnulib-hg
annotate lib/isdir.c @ 9364:559ef0e161fe
New module: xprintf
* modules/xprintf, lib/xprintf.c, lib/xprintf.h: New files.
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Fri, 19 Oct 2007 17:09:37 +0200 |
parents | bbbbbf4cd1c5 |
children | 3ee6b222df37 |
rev | line source |
---|---|
5 | 1 /* isdir.c -- determine whether a directory exists |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
2 |
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
3 Copyright (C) 1990, 1998, 2006 Free Software Foundation, Inc. |
5 | 4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
5 | 6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
8 (at your option) any later version. |
5 | 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 | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
5 | 17 |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
18 #include <config.h> |
287
349cc607da80
Use SAFE_STAT instead of stat to avoid unnecessary failure
Jim Meyering <jim@meyering.net>
parents:
5
diff
changeset
|
19 |
5 | 20 #include <sys/types.h> |
21 #include <sys/stat.h> | |
22 | |
1290 | 23 #if STAT_MACROS_BROKEN |
1278
9ad625a30b7d
Use #if, not #ifdef with HAVE_ macros
Jim Meyering <jim@meyering.net>
parents:
650
diff
changeset
|
24 # undef S_ISDIR |
1290 | 25 #endif |
287
349cc607da80
Use SAFE_STAT instead of stat to avoid unnecessary failure
Jim Meyering <jim@meyering.net>
parents:
5
diff
changeset
|
26 |
1290 | 27 #if !defined S_ISDIR && defined S_IFDIR |
28 # define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR) | |
5 | 29 #endif |
30 | |
31 /* If PATH is an existing directory or symbolic link to a directory, | |
32 return nonzero, else 0. */ | |
33 | |
34 int | |
1557 | 35 isdir (const char *path) |
5 | 36 { |
37 struct stat stats; | |
38 | |
427
e452fef20925
(isdir): Usage stat, not safe_stat.
Jim Meyering <jim@meyering.net>
parents:
381
diff
changeset
|
39 return stat (path, &stats) == 0 && S_ISDIR (stats.st_mode); |
5 | 40 } |