Add some more (macro) file operation wrappers Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
diff --git a/src/fileops.c b/src/fileops.c
index b3715dc..f101cec 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -61,7 +61,7 @@ int gitfo_exists(const char *path)
off_t gitfo_size(git_file fd)
{
struct stat sb;
- if (fstat(fd, &sb))
+ if (gitfo_fstat(fd, &sb))
return git_os_error();
return sb.st_size;
}
diff --git a/src/fileops.h b/src/fileops.h
index dc5b2ce..2da4231 100644
--- a/src/fileops.h
+++ b/src/fileops.h
@@ -61,12 +61,16 @@ extern int gitfo_creat(const char *path, int mode);
extern int gitfo_read(git_file fd, void *buf, size_t cnt);
extern int gitfo_write(git_file fd, void *buf, size_t cnt);
+#define gitfo_lseek(f,n,w) lseek(f, n, w)
extern off_t gitfo_size(git_file fd);
extern int gitfo_read_file(gitfo_buf *obj, const char *path);
extern void gitfo_free_buf(gitfo_buf *obj);
extern int gitfo_move_file(char *from, char *to);
+#define gitfo_stat(p,b) stat(p, b)
+#define gitfo_fstat(f,b) fstat(f, b)
+
#define gitfo_unlink(p) unlink(p)
#define gitfo_rmdir(p) rmdir(p)
#define gitfo_chdir(p) chdir(p)
diff --git a/src/odb.c b/src/odb.c
index 58840c6..8157f9e 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -1016,7 +1016,7 @@ static int pack_stat(git_pack *p)
p->pack_name) < 0)
return GIT_ERROR;
- if (stat(pb, &sb) || !S_ISREG(sb.st_mode))
+ if (gitfo_stat(pb, &sb) || !S_ISREG(sb.st_mode))
return GIT_ERROR;
if (sb.st_size < (3 * 4 + GIT_OID_RAWSZ))