summaryrefslogtreecommitdiff
path: root/src
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 /src
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 'src')
-rw-r--r--src/os/unix.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/os/unix.c b/src/os/unix.c
index 767f20ca8..8a2088414 100644
--- a/src/os/unix.c
+++ b/src/os/unix.c
@@ -23,7 +23,6 @@
* Boston, MA 02110-1301, USA.
*/
-#include <errno.h>
#include "git/common.h"
int git_fopen(git_file *out, const char *path, int flags)
@@ -74,3 +73,11 @@ int git_fwrite(git_file fd, void *buf, size_t cnt)
}
return GIT_SUCCESS;
}
+
+off_t git_fsize(git_file fd)
+{
+ struct stat sb;
+ if (fstat(fd, &sb))
+ return -1;
+ return sb.st_size;
+}