summaryrefslogtreecommitdiff
path: root/gnu/libexec/uucp/libunix/size.c
blob: 8d021db3cd5c052ae85411db7ca030aeba4fdff0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
}