diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-06-23 21:33:09 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-06-23 21:33:09 +0000 |
commit | 38b530a8b818a95f74a013e61c4a1a3f4b295221 (patch) | |
tree | 30d5731a56d33c397fcea8b3ca9526cb220ad396 /epan | |
parent | 7ad0ca82b1e58101bba7cadff5114eeaf8d098c6 (diff) | |
download | wireshark-38b530a8b818a95f74a013e61c4a1a3f4b295221.tar.gz |
Add a routine to "epan/filesystem.c" to test whether a file is a FIFO.
Use that in Tethereal rather than duplicating a pile of macros.
Get rid of the remaining uses of "stat()" in Tethereal - none of them
are necessary (they were just cut-and-pasted from Ethereal).
svn path=/trunk/; revision=5746
Diffstat (limited to 'epan')
-rw-r--r-- | epan/filesystem.c | 16 | ||||
-rw-r--r-- | epan/filesystem.h | 15 |
2 files changed, 29 insertions, 2 deletions
diff --git a/epan/filesystem.c b/epan/filesystem.c index 247512fb90..ffb487445e 100644 --- a/epan/filesystem.c +++ b/epan/filesystem.c @@ -1,7 +1,7 @@ /* filesystem.c * Filesystem utility routines * - * $Id: filesystem.c,v 1.17 2002/03/02 20:48:10 guy Exp $ + * $Id: filesystem.c,v 1.18 2002/06/23 21:33:09 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -195,6 +195,20 @@ test_for_directory(const char *path) return 0; } +int +test_for_fifo(const char *path) +{ + struct stat statb; + + if (stat(path, &statb) < 0) + return errno; + + if (S_ISFIFO(statb.st_mode)) + return ESPIPE; + else + return 0; +} + /* * Get the directory in which Ethereal's global configuration and data * files are stored. diff --git a/epan/filesystem.h b/epan/filesystem.h index 6ad4078473..44f51748dc 100644 --- a/epan/filesystem.h +++ b/epan/filesystem.h @@ -1,7 +1,7 @@ /* filesystem.h * Filesystem utility definitions * - * $Id: filesystem.h,v 1.10 2001/10/24 07:18:37 guy Exp $ + * $Id: filesystem.h,v 1.11 2002/06/23 21:33:09 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -58,6 +58,19 @@ char *get_dirname(char *); int test_for_directory(const char *); /* + * Given a pathname, return: + * + * the errno, if an attempt to "stat()" the file fails; + * + * ESPIPE, if the attempt succeeded and the file turned out + * to be a FIFO; + * + * 0, if the attempt succeeded and the file turned out not + * to be a FIFO. + */ +int test_for_fifo(const char *); + +/* * Get the directory in which global configuration and data files are * stored. */ |