From 66c908ee6c2222fe50a174f07f395922dc4c5d84 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 4 Oct 2004 16:43:14 +0000 Subject: [PATCH] Added sh_file_size() (stat() isn't reliable on large files on some systems). --- lib/lfs.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/lfs.h b/lib/lfs.h index ee9b71b1..6b28936f 100644 --- a/lib/lfs.h +++ b/lib/lfs.h @@ -37,4 +37,15 @@ #define SHERLOCK_HAVE_PREAD +static inline sh_off_t +sh_file_size(byte *name) +{ + int fd = open(name, O_RDONLY); + if (fd < 0) + die("Cannot open %s: %m", name); + sh_off_t len = sh_seek(fd, 0, SEEK_SET); + close(fd); + return len; +} + #endif /* !_SHERLOCK_LFS_H */ -- 2.39.2