Skip to content
This repository
Browse code

Add with_lib function

  • Loading branch information...
commit 7f402b0b814d45dd4669944c38e0efeba6298b8b 1 parent a5099b0
Winston Chang authored December 15, 2012

Showing 1 changed file with 16 additions and 1 deletion. Show diff stats Hide diff stats

  1. 17  R/with.r
17  R/with.r
@@ -4,7 +4,8 @@
4 4
 #'   \item \code{in_dir}: working directory
5 5
 #'   \item \code{with_collate}: collation order
6 6
 #'   \item \code{with_env}: environmental variables
7  
-#'   \item \code{with_libpaths}: library paths
  7
+#'   \item \code{with_libpaths}: library paths, replacing current libpaths
  8
+#'   \item \code{with_lib}: library paths, prepending to current libpaths
8 9
 #'   \item \code{with_locale}: any locale setting
9 10
 #'   \item \code{with_options}: options
10 11
 #'   \item \code{with_path}: PATH environment variable
@@ -94,6 +95,20 @@ set_libpaths <- function(paths) {
94 95
 #' @export
95 96
 with_libpaths <- with_something(set_libpaths)
96 97
 
  98
+# lib ------------------------------------------------------------------------
  99
+
  100
+set_lib <- function(paths) {
  101
+  libpath <- normalizePath(paths, mustWork = TRUE)
  102
+
  103
+  old <- .libPaths()
  104
+  .libPaths(c(libpath, .libPaths()))
  105
+  invisible(old)
  106
+}
  107
+
  108
+#' @rdname with_something
  109
+#' @export
  110
+with_lib <- with_something(set_lib)
  111
+
97 112
 # options --------------------------------------------------------------------
98 113
 
99 114
 #' @rdname with_something

0 notes on commit 7f402b0

Please sign in to comment.
Something went wrong with that request. Please try again.