-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
58 lines (43 loc) · 1.65 KB
/
README.Rmd
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
output:
github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# dqmagic
[](https://travis-ci.org/daqana/dqmagic)
[](https://codecov.io/github/daqana/dqmagic?branch=master)
The dqmagic package provides an R interface for the [libmagic](https://linux.die.net/man/3/libmagic)
file type identification library similar to the Unix [file](https://linux.die.net/man/1/file)
command. This allows for file type identification based on a file's content instead of it's extension.
## Installation
In order to install and use dqmagic you will need the `libmagic` library and headers:
* Debian/Ubuntu: `sudo apt-get install libmagic-dev`
* Fedora/CentOS/RHEL: `sudo yum install file-devel`
* OSX with homebrew: `brew install libmagic`
At the moment dqmagic is not on CRAN, but you can install the current version
via [drat](https://cran.r-project.org/package=drat):
```r
if (!requireNamespace("drat", quietly = TRUE)) install.packages("drat")
drat::addRepo("daqana")
install.packages("dqmagic")
```
## Examples
This is a basic example which shows you how to determine the type of a file:
```{r}
library(dqmagic)
file_type("DESCRIPTION")
file_type("src/file.cpp")
```
And the same for the MIME type and encoding:
```{r}
library(dqmagic)
file_type("DESCRIPTION", mime_type = TRUE, mime_encoding = TRUE)
file_type("src/file.cpp", mime_type = TRUE, mime_encoding = TRUE)
```