Bob Rudis
8 years ago
No known key found for this signature in database
GPG Key ID: 1D7529BE14E2BBA9
3 changed files with
22 additions and
13 deletions
-
R/RcppExports.R
-
man/incant.Rd
-
src/wand.cpp
|
|
@ -1,10 +1,13 @@ |
|
|
|
# This file was generated by Rcpp::compileAttributes |
|
|
|
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 |
|
|
|
|
|
|
|
#' Return file info |
|
|
|
#' Retrieve 'magic' attributes from files and directories |
|
|
|
#' |
|
|
|
#' @param path character vector of files to use magic on |
|
|
|
#' @return a \code{tibble} / \code{data.frame} of file magic attributes |
|
|
|
#' @return a \code{tibble} / \code{data.frame} of file magic attributes. |
|
|
|
#' Specifically, mime type, encoding, possible file extensions and |
|
|
|
#' type description are returned as colums in the data frame along |
|
|
|
#' with \code{path}. |
|
|
|
#' @export |
|
|
|
#' @examples |
|
|
|
#' library(magrittr) |
|
|
|
|
|
@ -2,7 +2,7 @@ |
|
|
|
% Please edit documentation in R/RcppExports.R |
|
|
|
\name{incant} |
|
|
|
\alias{incant} |
|
|
|
\title{Return file info} |
|
|
|
\title{Retrieve 'magic' attributes from files and directories} |
|
|
|
\usage{ |
|
|
|
incant(path) |
|
|
|
} |
|
|
@ -10,10 +10,13 @@ incant(path) |
|
|
|
\item{path}{character vector of files to use magic on} |
|
|
|
} |
|
|
|
\value{ |
|
|
|
a \code{tibble} / \code{data.frame} of file magic attributes |
|
|
|
a \code{tibble} / \code{data.frame} of file magic attributes. |
|
|
|
Specifically, mime type, encoding, possible file extensions and |
|
|
|
type description are returned as colums in the data frame along |
|
|
|
with \code{path}. |
|
|
|
} |
|
|
|
\description{ |
|
|
|
Return file info |
|
|
|
Retrieve 'magic' attributes from files and directories |
|
|
|
} |
|
|
|
\examples{ |
|
|
|
library(magrittr) |
|
|
|
|
|
@ -4,10 +4,13 @@ using namespace Rcpp; |
|
|
|
#include "magic.h" |
|
|
|
#include "limits.h" |
|
|
|
|
|
|
|
//' Return file info
|
|
|
|
//' Retrieve 'magic' attributes from files and directories
|
|
|
|
//'
|
|
|
|
//' @param path character vector of files to use magic on
|
|
|
|
//' @return a \code{tibble} / \code{data.frame} of file magic attributes
|
|
|
|
//' @return a \code{tibble} / \code{data.frame} of file magic attributes.
|
|
|
|
//' Specifically, mime type, encoding, possible file extensions and
|
|
|
|
//' type description are returned as colums in the data frame along
|
|
|
|
//' with \code{path}.
|
|
|
|
//' @export
|
|
|
|
//' @examples
|
|
|
|
//' library(magrittr)
|
|
|
@ -21,6 +24,7 @@ using namespace Rcpp; |
|
|
|
DataFrame incant(CharacterVector path) { |
|
|
|
|
|
|
|
unsigned int input_size = path.size(); |
|
|
|
|
|
|
|
StringVector mime_type(input_size); |
|
|
|
StringVector encoding(input_size); |
|
|
|
StringVector extensions(input_size); |
|
|
@ -35,7 +39,6 @@ DataFrame incant(CharacterVector path) { |
|
|
|
|
|
|
|
int flags = MAGIC_MIME_TYPE; |
|
|
|
magic_t cookie = magic_open(flags); |
|
|
|
|
|
|
|
if (cookie == NULL) { |
|
|
|
mime_type[i] = NA_STRING; |
|
|
|
} else { |
|
|
|