From 7350e6337a2d94c2d2a105845fc78ba0ddc89ea5 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 31 Dec 2008 16:07:38 -0800 Subject: [PATCH] Define gitfo_exists to determine file presence When scanning the pack directory we need to see if the path name is present for ".idx" when we discover a ".pack" file. Signed-off-by: Shawn O. Pearce --- src/fileops.c | 6 ++++++ src/fileops.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/fileops.c b/src/fileops.c index 0867c7b57..16b9dc520 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -53,6 +53,12 @@ int gitfo_write(git_file fd, void *buf, size_t cnt) return GIT_SUCCESS; } +int gitfo_exists(const char *path) +{ + struct stat sb; + return stat(path, &sb); +} + off_t gitfo_size(git_file fd) { struct stat sb; diff --git a/src/fileops.h b/src/fileops.h index 86726c5a8..820e02cce 100644 --- a/src/fileops.h +++ b/src/fileops.h @@ -31,6 +31,7 @@ typedef struct { /* file io buffer */ } gitfo_buf; +extern int gitfo_exists(const char *path); extern int gitfo_open(const char *path, int flags); extern int gitfo_creat(const char *path, int mode); #define gitfo_close(fd) close(fd)