aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-06-29 18:04:59 -0700
committerGuy Harris <guy@alum.mit.edu>2015-06-30 02:34:54 +0000
commit63a78d45bce99d9c0147d8b9c0bd0f81badc3f5f (patch)
treeb26b7f4d0ff5b1cfd51da639334b44fbbed2a19e /wsutil
parent1e511d830eac041815db3287934b6b84370b8f16 (diff)
Use ws_fstat64() to determine the size of an open file.
fseek() to the end, followed by ftell(), is a bit of an odd way to get the file size. Use ws_fstat64() instead. Check that the file is a regular file, while we're at it. This means we don't have to check before opening. Bug: 11268 Change-Id: I31ee20dd5568d10541375cf97b286abfc1384d1c Reviewed-on: https://code.wireshark.org/review/9230 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/file_util.h18
-rw-r--r--wsutil/filesystem.c19
2 files changed, 18 insertions, 19 deletions
diff --git a/wsutil/file_util.h b/wsutil/file_util.h
index 9bdbc34e9f..833518a9bc 100644
--- a/wsutil/file_util.h
+++ b/wsutil/file_util.h
@@ -40,6 +40,24 @@ extern "C" {
#include <sys/stat.h>
#endif
+/*
+ * Visual C++ on Win32 systems doesn't define these. (Old UNIX systems don't
+ * define them either.)
+ *
+ * Visual C++ on Win32 systems doesn't define S_IFIFO, it defines _S_IFIFO.
+ */
+#ifndef S_ISREG
+#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
+#endif
+#ifndef S_IFIFO
+#define S_IFIFO _S_IFIFO
+#endif
+#ifndef S_ISFIFO
+#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
+#endif
+#ifndef S_ISDIR
+#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
+#endif
#ifdef _WIN32
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index 9774d21b62..1006593730 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -194,25 +194,6 @@ get_dirname(char *path)
* to be a directory.
*/
-/*
- * Visual C++ on Win32 systems doesn't define these. (Old UNIX systems don't
- * define them either.)
- *
- * Visual C++ on Win32 systems doesn't define S_IFIFO, it defines _S_IFIFO.
- */
-#ifndef S_ISREG
-#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
-#endif
-#ifndef S_IFIFO
-#define S_IFIFO _S_IFIFO
-#endif
-#ifndef S_ISFIFO
-#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
-#endif
-#ifndef S_ISDIR
-#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
-#endif
-
int
test_for_directory(const char *path)
{