Browse Source

pkg rename

tags/v0.3.0
Bob Rudis 8 years ago
parent
commit
8951f320aa
  1. 7
      R/RcppExports.R
  2. 9
      man/incant.Rd
  3. 19
      src/wand.cpp

7
R/RcppExports.R

@ -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)

9
man/incant.Rd

@ -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)

19
src/wand.cpp

@ -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 {
@ -95,11 +98,11 @@ DataFrame incant(CharacterVector path) {
}
}
DataFrame df = DataFrame::create(_["file"] = path,
_["mime_type"] = mime_type,
_["encoding"] = encoding,
_["extensions"] = extensions,
_["description"] = description,
DataFrame df = DataFrame::create(_["file"] = path,
_["mime_type"] = mime_type,
_["encoding"] = encoding,
_["extensions"] = extensions,
_["description"] = description,
_["stringsAsFactors"] = false);
df.attr("class") = CharacterVector::create("tbl_df", "tbl", "data.frame");

Loading…
Cancel
Save