Browse Source

documentation tweaks

tags/v0.3.0
Bob Rudis 8 years ago
parent
commit
c60905a2f5
  1. 10
      man/incant.Rd
  2. 10
      src/wand.cpp

10
man/incant.Rd

@ -4,10 +4,14 @@
\alias{incant}
\title{Retrieve 'magic' attributes from files and directories}
\usage{
incant(path)
incant(path, magic_db = NA_character_)
}
\arguments{
\item{path}{character vector of files to use magic on}
\item{magic_db}{either \code{NULL} (the default) to use the built-in
\code{magic.mgc} database or an atomic character vector with a
colon-separated list of full paths to custom \code{magic.mgc} database(s).}
}
\value{
a \code{tibble} / \code{data.frame} of file magic attributes.
@ -27,4 +31,8 @@ system.file("img", package="filemagic") \%>\%
incant() \%>\%
glimpse()
}
\references{
See \url{http://openpreservation.org/blog/2012/08/09/magic-editing-and-creation-primer/}
for information on how to create your own \code{magic.mgc} databases.
}

10
src/wand.cpp

@ -30,6 +30,8 @@ DataFrame incant(CharacterVector path) {
StringVector extensions(input_size);
StringVector description(input_size);
const char *mtype = NULL;
for (unsigned int i=0; i<input_size; i++) {
if ((i % 10000) == 0) Rcpp::checkUserInterrupt();
@ -42,7 +44,7 @@ DataFrame incant(CharacterVector path) {
if (cookie == NULL) {
mime_type[i] = NA_STRING;
} else {
magic_load(cookie, NULL);
magic_load(cookie, mtype);
const char *magic_result = magic_file(cookie, fullPath.c_str());
if (magic_result == NULL) {
mime_type[i] = NA_STRING;
@ -57,7 +59,7 @@ DataFrame incant(CharacterVector path) {
if (cookie == NULL) {
encoding[i] = NA_STRING;
} else {
magic_load(cookie, NULL);
magic_load(cookie, mtype);
const char *magic_result = magic_file(cookie, fullPath.c_str());
if (magic_result == NULL) {
encoding[i] = NA_STRING;
@ -72,7 +74,7 @@ DataFrame incant(CharacterVector path) {
if (cookie == NULL) {
extensions[i] = NA_STRING;
} else {
magic_load(cookie, NULL);
magic_load(cookie, mtype);
const char *magic_result = magic_file(cookie, fullPath.c_str());
if (magic_result == NULL) {
extensions[i] = NA_STRING;
@ -87,7 +89,7 @@ DataFrame incant(CharacterVector path) {
if (cookie == NULL) {
description[i] = NA_STRING;
} else {
magic_load(cookie, NULL);
magic_load(cookie, mtype);
const char *magic_result = magic_file(cookie, fullPath.c_str());
if (magic_result == NULL) {
description[i] = NA_STRING;

Loading…
Cancel
Save