You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Bob Rudis 2834c5c19f
7 years ago
R rly working on Windows for sure now 7 years ago
inst ensured dir isn't empty 7 years ago
man rly working on Windows for sure now 7 years ago
src ensured dir isn't empty 7 years ago
tests ensured dir isn't empty 7 years ago
.Rbuildignore README 7 years ago
.gitignore initial commit 7 years ago
.travis.yml travis 7 years ago
DESCRIPTION spelling 7 years ago
NAMESPACE rly working on Windows for sure now 7 years ago works on Windows 7 years ago
README.Rmd README 7 years ago README 7 years ago works on Windows 7 years ago README 7 years ago
wand.Rproj pkg rename 7 years ago

Project Status: Active - The project has reached a stable, usable state and is being actively developed. Travis-CI Build Status

wand : Retrieve 'Magic' Attributes from Files and Directories

The libmagic library must be installed on *nix/macOS and available to use this.

  • apt-get install libmagic-dev on Debian-ish systems
  • brew install libmagic on macOS

While the package was developed using the 5.28 version of libmagic it has been configured to work with older versions. Note that some fields in the resultant data frame might not be available with older library versions. When using the function magic_wand_file() it checks for which version of libmagic is installed on your system and provides a suitable magic.mgc file for it.

The package also works on Windows but it's a bit of a hack because, well, Windows. The Windows version makes two system2() calls and relies on Rtools being installed and file.exe being available on the Windows PATH, so it's sub-optimal at best. Help to get it working in C would be greatly appreciated. Windows folk can go here to find out more info on Rtools.

The following functions are implemented:

  • incant : returns the "magic" metadata of the files in the input vector (as a data frame)
  • magic_wand_file : provides a full path to the package-provided magic file





system.file("img", package="wand") %>% 
  list.files(full.names=TRUE) %>% 
  incant() %>% 
## Observations: 10
## Variables: 5
## $ file        <chr> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/wand/img/example_dir", "/Librar...
## $ mime_type   <chr> "inode/directory", "text/x-c", "text/html", "text/plain", "text/rtf", "image/jpeg", "applicatio...
## $ encoding    <chr> "binary", "us-ascii", "us-ascii", "us-ascii", "us-ascii", "binary", "binary", "binary", "us-asc...
## $ extensions  <chr> NA, "???", "???", "???", "???", "jpeg/jpg/jpe/jfif", "???", "???", "???", "???"
## $ description <chr> "directory", "C source, ASCII text", "HTML document, ASCII text, with CRLF line terminators", "...
# Use a non-system magic-file

system.file("img", package="wand") %>% 
  list.files(full.names=TRUE) %>% 
  incant(magic_wand_file()) %>% 
  select(description) %>% 
##  [1] "directory"                                                                                                                                                                                                        
##  [2] "C source, ASCII text"                                                                                                                                                                                             
##  [3] "HTML document, ASCII text, with CRLF line terminators"                                                                                                                                                            
##  [4] "ASCII text, with no line terminators"                                                                                                                                                                             
##  [5] "Rich Text Format data, version 1, ANSI"                                                                                                                                                                           
##  [6] "JPEG image data, JFIF standard 1.01, aspect ratio, density 72x72, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=2, orientation=upper-left], baseline, precision 8, 800x700, frames 3"
##  [7] "PDF document, version 1.3"                                                                                                                                                                                        
##  [8] "PNG image data, 800 x 700, 8-bit/color RGBA, non-interlaced"                                                                                                                                                      
##  [9] "ASCII text, with very long lines, with CRLF line terminators"                                                                                                                                                     
## [10] "TIFF image data, big-endian"
# current verison
## [1] '0.2.0'

Test Results


## [1] "Mon Aug 15 10:19:22 2016"
## testthat results ========================================================================================================
## DONE ===================================================================================================================