summaryrefslogtreecommitdiff
path: root/src/os_posix/os_filesize.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/os_posix/os_filesize.c')
-rw-r--r--src/os_posix/os_filesize.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/os_posix/os_filesize.c b/src/os_posix/os_filesize.c
new file mode 100644
index 00000000000..42daf86cd86
--- /dev/null
+++ b/src/os_posix/os_filesize.c
@@ -0,0 +1,29 @@
+/*-
+ * Copyright (c) 2008-2012 WiredTiger, Inc.
+ * All rights reserved.
+ *
+ * See the file LICENSE for redistribution information.
+ */
+
+#include "wt_internal.h"
+
+/*
+ * __wt_filesize --
+ * Get the size of a file in bytes.
+ */
+int
+__wt_filesize(WT_SESSION_IMPL *session, WT_FH *fh, off_t *sizep)
+{
+ struct stat sb;
+ int ret;
+
+ WT_VERBOSE(session, fileops, "%s: fstat", fh->name);
+
+ WT_SYSCALL_RETRY(fstat(fh->fd, &sb), ret);
+ if (ret == 0) {
+ *sizep = sb.st_size;
+ return (0);
+ }
+
+ WT_RET_MSG(session, ret, "%s: fstat", fh->name);
+}