diff options
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | 2006-12-20 17:37:07 +0100 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-12-21 23:10:14 -0800 |
commit | 7cab5883ffd643916d0322a1d3360a79ccf6f653 (patch) | |
tree | b053fdaa042bab6106c8b50baedccf100c28aec1 /xdiff-interface.c | |
parent | fa39b6b5b11f9b580c515a7b4a8e4eb8eaa79b75 (diff) | |
download | git-7cab5883ffd643916d0322a1d3360a79ccf6f653.tar.gz |
move read_mmfile() into xdiff-interface
read_file() was a useful function if you want to work with the xdiff stuff,
so it was renamed and put into a more central place.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'xdiff-interface.c')
-rw-r--r-- | xdiff-interface.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/xdiff-interface.c b/xdiff-interface.c index 08602f5221..6c1f99b149 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -102,3 +102,22 @@ int xdiff_outf(void *priv_, mmbuffer_t *mb, int nbuf) } return 0; } + +int read_mmfile(mmfile_t *ptr, const char *filename) +{ + struct stat st; + FILE *f; + + if (stat(filename, &st)) + return error("Could not stat %s", filename); + if ((f = fopen(filename, "rb")) == NULL) + return error("Could not open %s", filename); + ptr->ptr = xmalloc(st.st_size); + if (fread(ptr->ptr, st.st_size, 1, f) != 1) + return error("Could not read %s", filename); + fclose(f); + ptr->size = st.st_size; + return 0; +} + + |