summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2008-11-03 18:38:57 -0800
committerShawn O. Pearce <spearce@spearce.org>2008-11-03 18:52:28 -0800
commit2dbdb824f0cfbf5f583e6b94aec753f276ed3368 (patch)
treeebae795e1fd8502328b176c3f63a4320c91de800 /include
parent3e9e69098af2014a0c3fe9e46cddcb5365dd538b (diff)
downloadlibgit2-2dbdb824f0cfbf5f583e6b94aec753f276ed3368.tar.gz
Add git_fsize to the os file API
This permits us to get the size of an opened file. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'include')
-rw-r--r--include/git/os/unix.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/git/os/unix.h b/include/git/os/unix.h
index 56f77b95f..475fe13a5 100644
--- a/include/git/os/unix.h
+++ b/include/git/os/unix.h
@@ -26,11 +26,16 @@
#ifndef INCLUDE_git_os_abstraction_h__
#define INCLUDE_git_os_abstraction_h__
+/** Force 64 bit off_t size on POSIX. */
+#define _FILE_OFFSET_BITS 64
+
+#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <time.h>
+#include <stdlib.h>
#include <string.h>
/**
@@ -96,6 +101,15 @@ GIT_EXTERN(int) git_fread(git_file fd, void *buf, size_t cnt);
GIT_EXTERN(int) git_fwrite(git_file fd, void *buf, size_t cnt);
/**
+ * Get the current size of an open file.
+ * @param fd open descriptor.
+ * @return
+ * - On success, >= 0, indicating the file size in bytes.
+ * - On error, <0.
+ */
+GIT_EXTERN(off_t) git_fsize(git_file fd);
+
+/**
* Close an open file descriptor.
* @param fd descriptor to close.
* @return