]> mj.ucw.cz Git - libucw.git/commitdiff
Added sh_file_size() (stat() isn't reliable on large files on some systems).
authorMartin Mares <mj@ucw.cz>
Mon, 4 Oct 2004 16:43:14 +0000 (16:43 +0000)
committerMartin Mares <mj@ucw.cz>
Mon, 4 Oct 2004 16:43:14 +0000 (16:43 +0000)
lib/lfs.h

index ee9b71b11c3d5f4aa2eeb3e8791b6bf3b0deebc3..6b28936f77e46935499e6a08696602b8a5b60027 100644 (file)
--- a/lib/lfs.h
+++ b/lib/lfs.h
 
 #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 */