is_binary: Is blob binary

Description Usage Arguments Value Examples

View source: R/blob.R

Description

Is blob binary

Usage

1
is_binary(blob = NULL)

Arguments

blob

The blob object.

Value

TRUE if binary data, FALSE if not.

Examples

 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
## Not run: 
## Initialize a temporary repository
path <- tempfile(pattern="git2r-")
dir.create(path)
repo <- init(path)

## Create a user
config(repo, user.name = "Alice", user.email = "alice@example.org")

## Commit a text file
writeLines("Hello world!", file.path(path, "example.txt"))
add(repo, "example.txt")
commit_1 <- commit(repo, "First commit message")

## Check if binary
b_text <- tree(commit_1)["example.txt"]
is_binary(b_text)

## Commit plot file (binary)
x <- 1:100
y <- x^2
png(file.path(path, "plot.png"))
plot(y ~ x, type = "l")
dev.off()
add(repo, "plot.png")
commit_2 <- commit(repo, "Second commit message")

## Check if binary
b_png <- tree(commit_2)["plot.png"]
is_binary(b_png)

## End(Not run)

Example output

[1] FALSE
png 
  2 
[1] TRUE

git2r documentation built on Jan. 13, 2021, 8:40 a.m.

Related to is_binary in git2r...