From 4591e76a2d1aa07dc80eaa002b4ed7c58d81c242 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Fri, 10 Dec 2021 15:19:59 -0500 Subject: blob: identify binary content Introduce `git_blob_data_is_binary` to examine a blob's data, instead of the blob itself. A replacement for `git_buf_is_binary`. --- include/git2/blob.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/git2/blob.h') diff --git a/include/git2/blob.h b/include/git2/blob.h index 4922b087a..59fac9e20 100644 --- a/include/git2/blob.h +++ b/include/git2/blob.h @@ -284,6 +284,18 @@ GIT_EXTERN(int) git_blob_create_from_buffer( */ GIT_EXTERN(int) git_blob_is_binary(const git_blob *blob); +/** + * Determine if the given content is most certainly binary or not; + * this is the same mechanism used by `git_blob_is_binary` but only + * looking at raw data. + * + * @param data The blob data which content should be analyzed + * @param len The length of the data + * @return 1 if the content of the blob is detected + * as binary; 0 otherwise. + */ +GIT_EXTERN(int) git_blob_data_is_binary(const char *data, size_t len); + /** * Create an in-memory copy of a blob. The copy must be explicitly * free'd or it will leak. -- cgit v1.2.1