[R-gregmisc-users] SF.net SVN: r-gregmisc:[1452] trunk/gdata/R
Brought to you by:
warnes
From: <wa...@us...> - 2010-10-19 22:04:55
|
Revision: 1452 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1452&view=rev Author: warnes Date: 2010-10-19 22:04:49 +0000 (Tue, 19 Oct 2010) Log Message: ----------- Avoid use of file.access() which is unreliable on Windows network shares. Modified Paths: -------------- trunk/gdata/R/onAttach.R trunk/gdata/R/xls2sep.R Modified: trunk/gdata/R/onAttach.R =================================================================== --- trunk/gdata/R/onAttach.R 2010-08-14 19:28:55 UTC (rev 1451) +++ trunk/gdata/R/onAttach.R 2010-10-19 22:04:49 UTC (rev 1452) @@ -1,8 +1,13 @@ .onAttach <- function(libname, pkgname) { show <- function(...) - writeLines(strwrap( x=list(...), prefix="gdata: " )) - + packageStartupMessage( + paste( + strwrap(x = list(...), + prefix = "gdata: "), + collapse="\n",sep="\n" + ) + ) try( { Modified: trunk/gdata/R/xls2sep.R =================================================================== --- trunk/gdata/R/xls2sep.R 2010-08-14 19:28:55 UTC (rev 1451) +++ trunk/gdata/R/xls2sep.R 2010-10-19 22:04:49 UTC (rev 1452) @@ -45,9 +45,6 @@ xls <- tf } - if(file.access(xls, 4)!=0) - stop("Unable to read xls file '", xls, "'." ) - if(method=="csv") { script <- file.path(perl.dir,'xls2csv.pl') @@ -95,21 +92,29 @@ ## ## do the translation if(verbose) cat("Executing '", cmd, "'... \n\n") - ## - results <- system(cmd, intern=!verbose) + + results <- try(system(cmd, intern=!verbose)) + + if(inherits(results, "try-error")) + stop( "Unable to read xls file '", xls, "':", results ) + if(verbose) cat(results,"\n\n") - ## if (verbose) cat("Done.\n\n") + ## + ## check that the target file was created ## + if(!file.exists(targetFile)) + stop( "Intermediate file '", targetFile, "' missing!" ) - if(file.access(targetFile, 4)!=0) - stop("Unable to read translated ", method, " file '", targetFile, "'." ) - - if (verbose) cat("Done.\n") + ## Creae a file object to hand to the next stage.. + retval <- try(file(targetFile)) + if(inherits(retval, "try-error")) + stop("Unable to open intermediate file '", targetFile, "':", + retval) - ## prepare for cleanup now, in case of error reading file - file(targetFile) + return(retval) + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |