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>
This commit is contained in:

committed by
Junio C Hamano

parent
fa39b6b5b1
commit
7cab5883ff
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user