[Dplr-commits] r1064 - in pkg/dplR: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Apr 24 09:59:32 CEST 2017


Author: mvkorpel
Date: 2017-04-24 09:59:32 +0200 (Mon, 24 Apr 2017)
New Revision: 1064

Modified:
   pkg/dplR/ChangeLog
   pkg/dplR/DESCRIPTION
   pkg/dplR/R/helpers.R
   pkg/dplR/R/rasterPlot.R
   pkg/dplR/R/read.tucson.R
Log:
Robustness against the rare missing tempdir()

See R-admin manual section 5 and recent discussion on R-devel list


Modified: pkg/dplR/ChangeLog
===================================================================
--- pkg/dplR/ChangeLog	2017-04-06 09:28:35 UTC (rev 1063)
+++ pkg/dplR/ChangeLog	2017-04-24 07:59:32 UTC (rev 1064)
@@ -6,6 +6,8 @@
 - Internal helper fix.names() is more robust when working in the C
   locale.
 
+- Added internal helper function check.tempdir()
+
 File: latexify.R
 ----------------
 
@@ -18,6 +20,13 @@
 - In rasterPlot(Cairo = TRUE, ...), added a version check for the Cairo
   package
 
+- Check if temporary directory is missing before use
+
+File: read.tucson.R
+----------------
+
+- Check if temporary directory is missing before use
+
 File: DESCRIPTION
 ----------------
 

Modified: pkg/dplR/DESCRIPTION
===================================================================
--- pkg/dplR/DESCRIPTION	2017-04-06 09:28:35 UTC (rev 1063)
+++ pkg/dplR/DESCRIPTION	2017-04-24 07:59:32 UTC (rev 1064)
@@ -3,7 +3,7 @@
 Type: Package
 Title: Dendrochronology Program Library in R
 Version: 1.6.6
-Date: 2017-04-06
+Date: 2017-04-24
 Authors at R: c(person("Andy", "Bunn", role = c("aut", "cph",
         "cre", "trl"), email = "andy.bunn at wwu.edu"), person("Mikko",
         "Korpela", role = c("aut", "trl")), person("Franco", "Biondi",

Modified: pkg/dplR/R/helpers.R
===================================================================
--- pkg/dplR/R/helpers.R	2017-04-06 09:28:35 UTC (rev 1063)
+++ pkg/dplR/R/helpers.R	2017-04-24 07:59:32 UTC (rev 1064)
@@ -1,3 +1,11 @@
+### Try to create directory named by tempdir() if it has gone missing
+check.tempdir <- function() {
+    td <- tempdir()
+    if (!file.exists(td)) {
+        dir.create(td)
+    }
+}
+
 ### Checks that all arguments are TRUE or FALSE
 check.flags <- function(...) {
     flag.bad <- vapply(list(...),

Modified: pkg/dplR/R/rasterPlot.R
===================================================================
--- pkg/dplR/R/rasterPlot.R	2017-04-06 09:28:35 UTC (rev 1063)
+++ pkg/dplR/R/rasterPlot.R	2017-04-24 07:59:32 UTC (rev 1064)
@@ -134,6 +134,7 @@
             cairoType <- "raster"
             cairoFile <- ""
         } else {
+            check.tempdir()
             cairoType <- "png"
             cairoFile <- fname
         }
@@ -141,9 +142,11 @@
                      units = "in", dpi = res, bg = bg,
                      type = cairoType, file = cairoFile, ...)
     } else if (missing(antialias)) {
+        check.tempdir()
         png(fname, width = pngWidthHeight[1], height = pngWidthHeight[2],
             units = "in", res = res, bg = bg, ...)
     } else {
+        check.tempdir()
         png(fname, width = pngWidthHeight[1], height = pngWidthHeight[2],
             units = "in", res = res, bg = bg, antialias = antialias, ...)
     }

Modified: pkg/dplR/R/read.tucson.R
===================================================================
--- pkg/dplR/R/read.tucson.R	2017-04-06 09:28:35 UTC (rev 1063)
+++ pkg/dplR/R/read.tucson.R	2017-04-24 07:59:32 UTC (rev 1064)
@@ -121,6 +121,7 @@
     ## Temporary file for 'goodLines'. Reading from this file is
     ## faster than making a textConnection to 'goodLines'.
     tf <- tempfile()
+    check.tempdir()
     tfcon <- file(tf, encoding="UTF-8")
     on.exit(close(tfcon))
     on.exit(unlink(tf), add=TRUE)



More information about the Dplr-commits mailing list