Skip to content

Commit

Permalink
modernize load hook, add backwards compatibility tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Sep 26, 2017
1 parent c514163 commit 3431725
Show file tree
Hide file tree
Showing 12 changed files with 327 additions and 225 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Description: Reads EXIF data using ExifTool <http://www.sno.phy.queensu.ca/~phil
Samsung, Sanyo, Sigma/Foveon and Sony.
License: GPL-2
LazyData: TRUE
Imports: purrr, dplyr, tibble, jsonlite, foreach, plyr, utils
Imports: curl, purrr, dplyr, tibble, jsonlite, foreach, plyr, utils
SystemRequirements: Perl
URL: https://github.com/paleolimbot/exifr
BugReports: https://github.com/paleolimbot/exifr/issues
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(configure_exiftool)
export(configure_perl)
export(exifr)
export(exiftool.call)
export(exiftool_call)
Expand Down
102 changes: 0 additions & 102 deletions R/getexif.R

This file was deleted.

5 changes: 5 additions & 0 deletions R/load_hook.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# .onLoad hook for when namespace is loaded
.onLoad <- function(libname, pkgname) {
configure_exiftool(quiet = TRUE, install_url = TRUE)
}
120 changes: 0 additions & 120 deletions R/loadhook.R

This file was deleted.

46 changes: 46 additions & 0 deletions R/read_exif_old.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

#' Read EXIF data
#'
#' This function has been deprecated, use \link{read_exif} instead.
#'
#' @param filename A vector of filenames (like that generated by
#' \code{list.files(..., full.names=TRUE)})
#' @param recursive If directory is specified by \code{filename}, process files recursively.
#' @param quiet \code{FALSE} if status updates are desired, \code{TRUE}
#' otherwise.
#' @param exiftoolargs a list of args to be passed to ExifTool (e.g. \code{c("-filename", "-imagesize")})
#'
#' @export
#'
exifr <- function(filename, recursive=FALSE, quiet=TRUE, exiftoolargs=NULL) {
message("exifr() is deprecated, and has been replaced by read_exif()")
read_exif(path = filename, recursive = recursive, args = exiftoolargs, quiet = quiet)
}

#' Call exiftool from R
#'
#' This function has been deprecated. Use \link{exiftool_call} instead.
#'
#' @param args a list of non-shell quoted arguments (e.g. \code{-n -csv})
#' @param fnames a list of filenames (\code{shQuote()} will be applied to this vector)
#' @param intern \code{TRUE} if output should be returned as a character vector.
#' @param ... additional arguments to be passed to \code{system()}
#'
#' @export
#'
exiftool.call <- function(args=c("--help"), fnames=NULL, intern=FALSE, ...) {
message("exiftool.call has been deprecated and has been replaced by exiftool_call()")
exiftool_call(args = args, fnames = fnames, intern = intern, ...)
}


# private helper command
exiftool.command <- function(args, fnames) {
exiftoolpath <- options("exifr.exiftoolcommand")$exifr.exiftoolcommand
if(is.null(exiftoolpath)) stop("ExifTool not properly installed")
if(length(fnames) > 0) {
paste(exiftoolpath, paste(args, collapse=" "), paste(shQuote(fnames), collapse=" "))
} else {
paste(exiftoolpath, paste(args, collapse=" "))
}
}
Loading

0 comments on commit 3431725

Please sign in to comment.