summaryrefslogtreecommitdiff
path: root/gnu/libexec/uucp/libunix/size.c
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/libexec/uucp/libunix/size.c')
-rw-r--r--gnu/libexec/uucp/libunix/size.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gnu/libexec/uucp/libunix/size.c b/gnu/libexec/uucp/libunix/size.c
new file mode 100644
index 00000000000..8d021db3cd5
--- /dev/null
+++ b/gnu/libexec/uucp/libunix/size.c
@@ -0,0 +1,27 @@
+/* size.c
+ Get the size in bytes of a file. */
+
+#include "uucp.h"
+
+#include "uudefs.h"
+#include "sysdep.h"
+#include "system.h"
+
+#include <errno.h>
+
+long
+csysdep_size (zfile)
+ const char *zfile;
+{
+ struct stat s;
+
+ if (stat ((char *) zfile, &s) < 0)
+ {
+ if (errno == ENOENT)
+ return -1;
+ ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno));
+ return -2;
+ }
+
+ return s.st_size;
+}