Bob Rudis
7 years ago
No known key found for this signature in database
GPG Key ID: 1D7529BE14E2BBA9
9 changed files with
24 additions and
3 deletions
-
R/RcppExports.R
-
R/zzz.r
-
inst/db/new/magic.mgc.zip
-
BIN
inst/db/old/magic.mgc.zip
-
man/incant.Rd
-
man/magic_wand_file.Rd
-
src/RcppExports.cpp
-
src/wand.cpp
|
|
@ -28,3 +28,7 @@ incant <- function(path, magic_db = "system") { |
|
|
|
.Call('wand_incant', PACKAGE = 'wand', path, magic_db) |
|
|
|
} |
|
|
|
|
|
|
|
lib_version <- function() { |
|
|
|
.Call('wand_lib_version', PACKAGE = 'wand') |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -26,8 +26,10 @@ magic_wand_file <- function(force=FALSE) { |
|
|
|
if (!dir.exists(cache)) dir.create(cache, showWarnings=FALSE) |
|
|
|
if (!dir.exists(cache)) return("system") |
|
|
|
|
|
|
|
if (lib_version() >= 528) vers <- "new" else vers <- "old" |
|
|
|
|
|
|
|
if (!file.exists(file.path(rappdirs::user_cache_dir("wandr"), "magic.mgc"))) { |
|
|
|
suppressWarnings(unzip(system.file("magic.mgc.zip", package="wand"), |
|
|
|
suppressWarnings(unzip(system.file("db", vers, "magic.mgc.zip", package="wand"), |
|
|
|
exdir=cache, overwrite=force)) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -22,6 +22,10 @@ a \code{tibble} / \code{data.frame} of file magic attributes. |
|
|
|
\description{ |
|
|
|
Retrieve 'magic' attributes from files and directories |
|
|
|
} |
|
|
|
\note{ |
|
|
|
Various fields might not be available depending on the version |
|
|
|
of \code{libmagic} you have installed. |
|
|
|
} |
|
|
|
\examples{ |
|
|
|
library(magrittr) |
|
|
|
library(dplyr) |
|
|
|
|
|
@ -20,8 +20,6 @@ perform the decompression unless \code{force} is \code{TRUE} or the |
|
|
|
cache directory has been cleared. |
|
|
|
} |
|
|
|
\examples{ |
|
|
|
library(magrittr) |
|
|
|
library(dplyr) |
|
|
|
|
|
|
|
system.file("img", package="filemagic") \%>\% |
|
|
|
list.files(full.names=TRUE) \%>\% |
|
|
|
|
|
@ -17,3 +17,13 @@ BEGIN_RCPP |
|
|
|
return __result; |
|
|
|
END_RCPP |
|
|
|
} |
|
|
|
// lib_version
|
|
|
|
int lib_version(); |
|
|
|
RcppExport SEXP wand_lib_version() { |
|
|
|
BEGIN_RCPP |
|
|
|
Rcpp::RObject __result; |
|
|
|
Rcpp::RNGScope __rngScope; |
|
|
|
__result = Rcpp::wrap(lib_version()); |
|
|
|
return __result; |
|
|
|
END_RCPP |
|
|
|
} |
|
|
|
|
|
@ -145,3 +145,6 @@ DataFrame incant(CharacterVector path, std::string magic_db="system") { |
|
|
|
return(df); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// [[Rcpp::export]]
|
|
|
|
int lib_version() { return(magic_version()); } |
|
|
|