summaryrefslogtreecommitdiff
path: root/src/fileops.h
diff options
context:
space:
mode:
authorAndreas Ericsson <ae@op5.se>2008-11-29 15:28:12 +0100
committerShawn O. Pearce <spearce@spearce.org>2008-12-02 09:17:42 -0800
commit4188d28f1c38240392d896fc79561cc461fb12c0 (patch)
tree3d40a87326d25342300fb50d78744671440c5408 /src/fileops.h
parentec250c6e18e56d12714f9010e1b15e5feec5f473 (diff)
downloadlibgit2-4188d28f1c38240392d896fc79561cc461fb12c0.tar.gz
Add an io caching layer to the gitfo api
The idea is taken from Junio's work in read-cache.c, where it's used for writing out the index without tap-dancing on the poor harddrive. Since it's almost certainly useful for cached writing of packfiles too, we turn it into a generic API, making it perfectly simple to reuse it later. gitfo_write_cached() has the same contract as gitfo_write(), it returns GIT_SUCCESS if all bytes are successfully written (or were at least buffered for later writing), and <0 if an error occurs during buffer writing. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'src/fileops.h')
-rw-r--r--src/fileops.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/fileops.h b/src/fileops.h
index 32d6b9111..56d0888fe 100644
--- a/src/fileops.h
+++ b/src/fileops.h
@@ -21,6 +21,7 @@
typedef int git_file;
typedef struct stat gitfo_statbuf;
+typedef struct gitfo_cache gitfo_cache;
#define gitfo_open(path, flags) open(path, flags)
#define gitfo_close(fd) close(fd)
@@ -34,4 +35,9 @@ extern off_t gitfo_size(git_file fd);
#define gitfo_stat(path, buf) stat(path, buf)
#define gitfo_fsync(fd) fsync(fd)
+extern gitfo_cache *gitfo_enable_caching(git_file fd, size_t cache_size);
+extern int gitfo_write_cached(gitfo_cache *ioc, void *buf, size_t len);
+extern int gitfo_flush_cached(gitfo_cache *ioc);
+extern int gitfo_close_cached(gitfo_cache *ioc);
+
#endif /* INCLUDE_fileops_h__ */