Git Product home page Git Product logo

dqmagic's Introduction

dqmagic

Travis-CI Build Status Coverage Status

The dqmagic package provides an R interface for the libmagic file type identification library similar to the Unix file command. This allows for file type identification based on a file’s content instead of it’s extension.

Installation

In order to install and use dqmagic you will need the libmagic library and headers:

  • Debian/Ubuntu: sudo apt-get install libmagic-dev
  • Fedora/CentOS/RHEL: sudo yum install file-devel
  • OSX with homebrew: brew install libmagic

At the moment dqmagic is not on CRAN, but you can install the current version via drat:

if (!requireNamespace("drat", quietly = TRUE)) install.packages("drat")
drat::addRepo("daqana")
install.packages("dqmagic")

Examples

This is a basic example which shows you how to determine the type of a file:

library(dqmagic)
file_type("DESCRIPTION")
#> [1] "ASCII text"
file_type("src/file.cpp")
#> [1] "C source, ASCII text"

And the same for the MIME type and encoding:

library(dqmagic)
file_type("DESCRIPTION", mime_type = TRUE, mime_encoding = TRUE)
#> [1] "text/plain; charset=us-ascii"
file_type("src/file.cpp", mime_type = TRUE, mime_encoding = TRUE)
#> [1] "text/x-c; charset=us-ascii"

dqmagic's People

Contributors

adamhsparks avatar rstub avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

nikanpersian

dqmagic's Issues

dqmagic for windows user

Hi,

When I try to install dqmagic on windows I have this error :

> if (!requireNamespace("drat", quietly = TRUE)) install.packages("drat")
> drat::addRepo("RInstitute")
> install.packages("dqmagic")
Installing package into ‘C:/Users/Vincent/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
  unable to access index for repository https://RInstitute.github.io/drat/bin/windows/contrib/3.4:
  cannot open URL 'https://RInstitute.github.io/drat/bin/windows/contrib/3.4/PACKAGES'
Package which is only available in source form, and may need compilation
  of C/C++/Fortran: ‘dqmagic’
Do you want to attempt to install these from sources?
y/n: y
installing the source package ‘dqmagic’

trying URL 'https://RInstitute.github.io/drat/src/contrib/dqmagic_0.0.3.tar.gz'
Content type 'application/gzip' length 53896 bytes (52 KB)
downloaded 52 KB

* installing *source* package 'dqmagic' ...

   **********************************************
   WARNING: this package has a configure script
         It probably needs manual configuration
   **********************************************


** libs

*** arch - i386
C:/RBuildTools/3.4/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.3/include" -DNDEBUG  -I"C:/Users/Vincent/Documents/R/win-library/3.4/Rcpp/include"        -O2 -Wall  -mtune=generic -c RcppExports.cpp -o RcppExports.o
C:/RBuildTools/3.4/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.3/include" -DNDEBUG  -I"C:/Users/Vincent/Documents/R/win-library/3.4/Rcpp/include"        -O2 -Wall  -mtune=generic -c file.cpp -o file.o
file.cpp:23:19: fatal error: magic.h: No such file or directory
 #include <magic.h>
                   ^
compilation terminated.
make: *** [file.o] Error 1
Warning: l'exécution de la commande 'make -f "C:/PROGRA~1/R/R-34~1.3/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-34~1.3/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="dqmagic.dll" OBJECTS="RcppExports.o file.o magic.o"' renvoie un statut 2
ERROR: compilation failed for package 'dqmagic'
* removing 'C:/Users/Vincent/Documents/R/win-library/3.4/dqmagic'
In R CMD INSTALL
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-34~1.3/bin/x64/R" CMD INSTALL -l "C:\Users\Vincent\Documents\R\win-library\3.4" C:\Users\Vincent\AppData\Local\Temp\Rtmpiwpwzl/downloaded_packages/dqmagic_0.0.3.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘dqmagic’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\Vincent\AppData\Local\Temp\Rtmpiwpwzl\downloaded_packages’

Any ide how to correct this ?

regards

Include libmagic code?

Currently the CI builds on Mac OS are failing, most likely because of different libmagic versions. Possible solution:

  • Include the libmagic source in the package since it is reasonably small and needed for Windows support anyway
  • During configure configure and build libmagic if no usable installation is found
  • On Windows always build the included sources, which have to be pre-configured, since Rtools are not sufficient to run configure

Open questions:

  • What should be the default if a usable libmagic installation is found?

Problem with C++ compiler during installation under R 3.6

After upgrading to R 3.6, I get a C++ compiler error when installing dqmagic:

> install.packages("dqmagic_0.0.3.tar.gz", repos = NULL, type="source")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘dqmagic’ ...
** using staged installation
checking whether the C++ compiler works... no
configure: error: in `/tmp/RtmphLPkAd/R.INSTALL205f685bc685/dqmagic':
configure: error: C++ compiler cannot create executables
See `config.log' for more details

Since the config.log mentions problems with CXX1 and similar, I commented out some lines in the package configure file below the following line:

# use deprecated CXX1X* to support R versions 3.1.0 to 3.3.3

This is a workaround that worked for me. But perhaps, according to the comment above, it may cause problems with other R versions?

Thanks and best!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.