[Rprotobuf-commits] r924 - in pkg: . R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 1 23:53:20 CET 2014


Author: murray
Date: 2014-12-01 23:53:20 +0100 (Mon, 01 Dec 2014)
New Revision: 924

Modified:
   pkg/ChangeLog
   pkg/R/serialize.R
   pkg/R/wrapper_ZeroCopyInputStream.R
   pkg/inst/NEWS.Rd
Log:
Address a FIXME in the code and comment from JSS referee about
aboiding file.create to get absolute pathname of temporary file.  Use
normalizePath with mustWork=FALSE as suggested by Jeroen.



Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2014-12-01 21:58:07 UTC (rev 923)
+++ pkg/ChangeLog	2014-12-01 22:53:20 UTC (rev 924)
@@ -1,3 +1,9 @@
+2014-12-01  Murray Stokely  <mstokely at google.com>
+
+	* R/wrapper_ZeroCopyInputStream.R: Avoid file.create for getting
+	absolute path of a temporary file name (JSS reviewer feedback)
+	* R/serialize.R: Idem.
+
 2014-11-26  Murray Stokely  <mstokely at google.com>
 
 	Address feedback from anonymous reviewer for JSS to make this

Modified: pkg/R/serialize.R
===================================================================
--- pkg/R/serialize.R	2014-12-01 21:58:07 UTC (rev 923)
+++ pkg/R/serialize.R	2014-12-01 22:53:20 UTC (rev 924)
@@ -14,10 +14,10 @@
 		if( is.character( connection ) ){
 			# pretend it is a file name
 			if( !file.exists(connection) ){
-				# FIXME: hack to grab the absolute path name
-				file.create( connection )
-				file <- file_path_as_absolute(connection)
-				unlink( file )
+				if( !file.exists( dirname(connection) ) ){
+					stop( "directory does not exist" )
+				}
+				file <- normalizePath(connection, mustWork=FALSE)
 			} else{
 				file <- file_path_as_absolute(connection)
 			}

Modified: pkg/R/wrapper_ZeroCopyInputStream.R
===================================================================
--- pkg/R/wrapper_ZeroCopyInputStream.R	2014-12-01 21:58:07 UTC (rev 923)
+++ pkg/R/wrapper_ZeroCopyInputStream.R	2014-12-01 22:53:20 UTC (rev 924)
@@ -128,9 +128,7 @@
 		if( !file.exists( dirname(filename) ) ){
 			stop( "directory does not exist" )
 		}
-		file.create( filename )
-		filename <- file_path_as_absolute(filename)
-		unlink( filename )
+		filename <- normalizePath(filename, mustWork=FALSE)
 	} else{
 		filename <- file_path_as_absolute(filename)
 	}

Modified: pkg/inst/NEWS.Rd
===================================================================
--- pkg/inst/NEWS.Rd	2014-12-01 21:58:07 UTC (rev 923)
+++ pkg/inst/NEWS.Rd	2014-12-01 22:53:20 UTC (rev 924)
@@ -2,7 +2,7 @@
 \title{News for Package \pkg{RProtoBuf}}
 \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
 
-\section{Changes in RProtoBuf version 0.4.2 (2014-??-??)}{
+\section{Changes in RProtoBuf version 0.4.2 (2014-12-??)}{
   \itemize{
     \item Address changes suggested by anonymous reviewers for our
     Journal of Statistical Software submission.
@@ -23,6 +23,8 @@
       with \code{serialize_pb} and \code{unserialize_pb} to make it
       easy to serialize into a protocol buffer all 100+ of the
       built-in datasets with R.
+    \item Use \code{normalizePath} instead of creating a temporary
+    file with \code{file.create} when getting absolute path names.
     \item Add unit tests for all of the above.
 }
 



More information about the Rprotobuf-commits mailing list