From: Martin Mares Date: Mon, 4 Oct 2004 16:43:14 +0000 (+0000) Subject: Added sh_file_size() (stat() isn't reliable on large files on some systems). X-Git-Tag: holmes-import~888 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=66c908ee6c2222fe50a174f07f395922dc4c5d84;p=libucw.git Added sh_file_size() (stat() isn't reliable on large files on some systems). --- 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 */