boB Rudis
8 years ago
43 changed files with 281 additions and 64 deletions
@ -0,0 +1,13 @@ |
|||||
|
For Linux/UNIX/macOS you need 'libmagic' installed which is a component of the |
||||
|
'file' utility: <https://github.com/file/file>. You can find out more information |
||||
|
on 'libmagic' and 'file' at this URL: <http://www.darwinsys.com/file/>. |
||||
|
|
||||
|
Here are the incantations you must use to get magic for your environment: |
||||
|
|
||||
|
- `apt-get install libmagic-dev` on Ubuntu/Debian-ish systems |
||||
|
- `brew install libmagic` on macOS |
||||
|
- `yum install file-devel` on RHEL/CentOS/Fedora |
||||
|
|
||||
|
For Windows you will need Rtools <https://cran.r-project.org/bin/windows/Rtools/> |
||||
|
version 3.3 or higher (it may work with older ones, but it's only been tested on |
||||
|
Rtools version 3.3 & 3.4). |
@ -1 +1 @@ |
|||||
response <- encoding <- NULL |
extensions <- mime_type <- response <- encoding <- NULL |
@ -0,0 +1,31 @@ |
|||||
|
#' @title MIME Types Database |
||||
|
#' @description This is a dataset of all mime types. It aggregates data from the |
||||
|
#' following sources: |
||||
|
#' |
||||
|
#' \itemize{ |
||||
|
#' \item \url{http://www.iana.org/assignments/media-types/media-types.xhtml} |
||||
|
#' \item \url{http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types} |
||||
|
#' \item \url{http://hg.nginx.org/nginx/raw-file/default/conf/mime.types} |
||||
|
#' } |
||||
|
#' |
||||
|
#' There are a total of four possible fields per element: |
||||
|
#' |
||||
|
#' \itemize{ |
||||
|
#' \item \code{source}: where the mime type is defined. If not set, it's |
||||
|
#' probably a custom media type. One of \code{apache}, \code{iana} or \code{nginx}. |
||||
|
#' \item \code{extensions}: a character vector of known extensions associated with this mime type. |
||||
|
#' \item \code{compressible}: whether a file of this type can be "gzipped" (mostly |
||||
|
#' useful in the context of serving up web content). |
||||
|
#' \item \code{charset}: the default charset associated with this type, if any. |
||||
|
#' } |
||||
|
#' |
||||
|
#' @docType data |
||||
|
#' @keywords datasets |
||||
|
#' @name mime_db |
||||
|
#' |
||||
|
#' @references Ingested from \url{https://github.com/jshttp/mime-db}. |
||||
|
#' @usage data(mime_db) |
||||
|
#' @note Last updated 2016-08-14; the only guaranteed field is \code{source} |
||||
|
#' @format A list with 1,883 elements and four named fields: \code{source}, |
||||
|
#' \code{compressible}, \code{extensions} & \code{charset}. |
||||
|
NULL |
@ -0,0 +1,4 @@ |
|||||
|
JSON_DB_URL <- "https://raw.githubusercontent.com/jshttp/mime-db/master/db.json" |
||||
|
|
||||
|
mime_db <- jsonlite::fromJSON(JSON_DB_URL, flatten=TRUE) |
||||
|
use_data(mime_db) |
@ -0,0 +1,45 @@ |
|||||
|
echo "Checking to see if libmagic is available..." |
||||
|
|
||||
|
: ${R_HOME=`R RHOME`} |
||||
|
if test -z "${R_HOME}"; then |
||||
|
echo "could not determine R_HOME" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
CC=`"${R_HOME}/bin/R" CMD config CC` |
||||
|
CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS` |
||||
|
CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS` |
||||
|
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS` |
||||
|
LDFLAGS=`"${R_HOME}/bin/R" CMD config LDFLAGS` |
||||
|
DYLIB_LDFLAGS=`"${R_HOME}/bin/R" CMD config DYLIB_LDFLAGS` |
||||
|
SHLIB_LDFLAGS=`"${R_HOME}/bin/R" CMD config SHLIB_LDFLAGS` |
||||
|
|
||||
|
temp_src=$(mktemp) |
||||
|
cat > ${temp_src} <<EOF |
||||
|
#include "src/magic.h" |
||||
|
int main() { |
||||
|
magic_t t = magic_open(MAGIC_NONE); |
||||
|
return(0) |
||||
|
} |
||||
|
EOF |
||||
|
|
||||
|
temp_exe=$(mktemp) |
||||
|
|
||||
|
${CC} ${CFLAGS} ${CPPFLAGS} ${LD_FLAGS} ${CXXFLAGS} ${DYLIB_LDFLAGS} ${SHLIB_LDFLAGS} -L/usr/local/lib -L/opt/local/lib -L/usr/lib -lmagic -o ${temp_exe} ${temp_src} &> /dev/null |
||||
|
|
||||
|
ccerr=$? |
||||
|
|
||||
|
rm ${temp_src} ${temp_exe} |
||||
|
|
||||
|
if [ "$ccerr" == 1 ] ; then |
||||
|
echo |
||||
|
echo |
||||
|
echo "The libmagic library was not found." |
||||
|
echo |
||||
|
echo "Please install it before installing this package." |
||||
|
echo |
||||
|
echo |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
exit 0 |
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
@ -0,0 +1,40 @@ |
|||||
|
% Generated by roxygen2: do not edit by hand |
||||
|
% Please edit documentation in R/datasets.r |
||||
|
\docType{data} |
||||
|
\name{mime_db} |
||||
|
\alias{mime_db} |
||||
|
\title{MIME Types Database} |
||||
|
\format{A list with 1,883 elements and four named fields: \code{source}, |
||||
|
\code{compressible}, \code{extensions} & \code{charset}.} |
||||
|
\usage{ |
||||
|
data(mime_db) |
||||
|
} |
||||
|
\description{ |
||||
|
This is a dataset of all mime types. It aggregates data from the |
||||
|
following sources: |
||||
|
|
||||
|
\itemize{ |
||||
|
\item \url{http://www.iana.org/assignments/media-types/media-types.xhtml} |
||||
|
\item \url{http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types} |
||||
|
\item \url{http://hg.nginx.org/nginx/raw-file/default/conf/mime.types} |
||||
|
} |
||||
|
|
||||
|
There are a total of four possible fields per element: |
||||
|
|
||||
|
\itemize{ |
||||
|
\item \code{source}: where the mime type is defined. If not set, it's |
||||
|
probably a custom media type. One of \code{apache}, \code{iana} or \code{nginx}. |
||||
|
\item \code{extensions}: a character vector of known extensions associated with this mime type. |
||||
|
\item \code{compressible}: whether a file of this type can be "gzipped" (mostly |
||||
|
useful in the context of serving up web content). |
||||
|
\item \code{charset}: the default charset associated with this type, if any. |
||||
|
} |
||||
|
} |
||||
|
\note{ |
||||
|
Last updated 2016-08-14; the only guaranteed field is \code{source} |
||||
|
} |
||||
|
\references{ |
||||
|
Ingested from \url{https://github.com/jshttp/mime-db}. |
||||
|
} |
||||
|
\keyword{datasets} |
||||
|
|
Loading…
Reference in new issue