Browse Source

magic files

tags/v0.3.0
Bob Rudis 6 years ago
parent
commit
140dc2e33b
  1. 4
      R/RcppExports.R
  2. 4
      R/zzz.r
  3. 0
      inst/db/new/magic.mgc.zip
  4. BIN
      inst/db/old/magic.mgc.zip
  5. 4
      man/incant.Rd
  6. 2
      man/magic_wand_file.Rd
  7. 10
      src/RcppExports.cpp
  8. 3
      src/wand.cpp

4
R/RcppExports.R

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

4
R/zzz.r

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

0
inst/magic.mgc.zip → inst/db/new/magic.mgc.zip

BIN
inst/db/old/magic.mgc.zip

Binary file not shown.

4
man/incant.Rd

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

2
man/magic_wand_file.Rd

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

10
src/RcppExports.cpp

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

3
src/wand.cpp

@ -145,3 +145,6 @@ DataFrame incant(CharacterVector path, std::string magic_db="system") {
return(df);
}
// [[Rcpp::export]]
int lib_version() { return(magic_version()); }

Loading…
Cancel
Save