diff --git a/R/filemanagement.R b/R/filemanagement.R index 415bb471..145d72fc 100644 --- a/R/filemanagement.R +++ b/R/filemanagement.R @@ -391,8 +391,7 @@ fileman_up <- function(name, #' #' The function names were chosen to match those of GNU coreutils. #' -#' The functions use the OpenSSL implementation of the \code{openssl} package, -#' and silently close file connections. +#' The functions use the OpenSSL implementation of the \code{openssl} package. #' Note that \code{n2khab} will mask #' \code{\link[tools:md5sum]{tools::md5sum()}}, #' which is a standalone implementation. @@ -412,7 +411,9 @@ fileman_up <- function(name, #' file2 <- tempfile() #' files <- c(file1, file2) #' file.create(files) -#' writeLines("some text", file(file2)) +#' con <- file(file2) +#' writeLines("some text", con) +#' close(con) #' #' # computing two alternative checksums: #' md5sum(files) @@ -436,7 +437,6 @@ md5sum <- function(files) { assert_that_allfiles_exist(files) checksums <- map_chr(files, ~paste(md5(file(.)))) names(checksums) <- basename(files) - silently_close_connections() return(checksums) } @@ -446,7 +446,6 @@ sha256sum <- function(files) { assert_that_allfiles_exist(files) checksums <- map_chr(files, ~paste(sha256(file(.)))) names(checksums) <- basename(files) - silently_close_connections() return(checksums) } @@ -460,10 +459,3 @@ assert_that_allfiles_exist <- function(x) { paste0(x[!exist], collapse = "\n"))) } -#' @keywords internal -silently_close_connections <- function() { - oldopt <- options(warn = -1)[[1]] - closeAllConnections() - options(warn = oldopt) -} - diff --git a/man/checksum.Rd b/man/checksum.Rd index 973c3aca..1a90f52d 100644 --- a/man/checksum.Rd +++ b/man/checksum.Rd @@ -25,8 +25,7 @@ They can be used to verify file integrity. \details{ The function names were chosen to match those of GNU coreutils. -The functions use the OpenSSL implementation of the \code{openssl} package, -and silently close file connections. +The functions use the OpenSSL implementation of the \code{openssl} package. Note that \code{n2khab} will mask \code{\link[tools:md5sum]{tools::md5sum()}}, which is a standalone implementation. @@ -37,7 +36,9 @@ file1 <- tempfile() file2 <- tempfile() files <- c(file1, file2) file.create(files) -writeLines("some text", file(file2)) +con <- file(file2) +writeLines("some text", con) +close(con) # computing two alternative checksums: md5sum(files)