diff --git a/R/busy-indicators.R b/R/busy-indicators.R index 026c1e541..e285bca74 100644 --- a/R/busy-indicators.R +++ b/R/busy-indicators.R @@ -220,7 +220,7 @@ spinnerOptions <- function(type = NULL, color = NULL, size = NULL, delay = NULL, if (!is.null(type)) { stopifnot(is.character(type) && length(type) == 1) if (file.exists(type) && grepl("\\.svg$", type)) { - typeRaw <- readBin(type, "raw", n = file.info(type)$size) + typeRaw <- readBin(type, "raw", n = file.size(type)) url <- sprintf("url('data:image/svg+xml;base64,%s')", rawToBase64(typeRaw)) } else { type <- rlang::arg_match(type, .busySpinnerTypes) diff --git a/R/middleware.R b/R/middleware.R index 385ce5301..834507bf5 100644 --- a/R/middleware.R +++ b/R/middleware.R @@ -226,7 +226,7 @@ staticHandler <- function(root) { return(NULL) content.type <- getContentType(abs.path) - response.content <- readBin(abs.path, 'raw', n=file.info(abs.path)$size) + response.content <- readBin(abs.path, 'raw', n=file.size(abs.path)) return(httpResponse(200, content.type, response.content)) }) } @@ -456,7 +456,7 @@ getResponseContentLength <- function(response, deleteOwnedContent) { if (deleteOwnedContent && isTRUE(response$content$owned)) { on.exit(unlink(response$content$file, recursive = FALSE, force = FALSE), add = TRUE) } - file.info(response$content$file)$size + file.size(response$content$file) } else { warning("HEAD request for unexpected content class ", class(response$content)[[1]]) NULL diff --git a/R/mock-session.R b/R/mock-session.R index 5f0977511..fdb88a73d 100644 --- a/R/mock-session.R +++ b/R/mock-session.R @@ -344,7 +344,7 @@ MockShinySession <- R6Class( #' @param file The file to be encoded #' @param contentType The content type of the base64-encoded string fileUrl = function(name, file, contentType='application/octet-stream') { - bytes <- file.info(file)$size + bytes <- file.size(file) if (is.na(bytes)) return(NULL) diff --git a/R/reactives.R b/R/reactives.R index 8d098c7f9..e8ce2a557 100644 --- a/R/reactives.R +++ b/R/reactives.R @@ -1965,7 +1965,7 @@ coerceToFunc <- function(x) { #' # This function returns the time that log_file was last modified #' checkFunc = function() { #' if (file.exists(log_file)) -#' file.info(log_file)$mtime[1] +#' file.mtime(log_file[1]) #' else #' "" #' }, @@ -2127,7 +2127,7 @@ reactiveFileReader <- function(intervalMillis, session, filePath, readFunc, ...) session = session, checkFunc = function() { path <- filePath() - info <- file.info(path) + info <- file.info(path, extra_cols = FALSE) return(paste(path, info$mtime, info$size)) }, valueFunc = function() { diff --git a/R/shiny.R b/R/shiny.R index d8cc2330c..dfa02e948 100644 --- a/R/shiny.R +++ b/R/shiny.R @@ -629,7 +629,7 @@ ShinySession <- R6Class( saveRDS(values, tmpfile) on.exit(unlink(tmpfile), add = TRUE) - content <- readBin(tmpfile, "raw", n = file.info(tmpfile)$size) + content <- readBin(tmpfile, "raw", n = file.size(tmpfile)) httpResponse(200, "application/octet-stream", content) } else { @@ -2096,7 +2096,7 @@ ShinySession <- R6Class( fileUrl = function(name, file, contentType='application/octet-stream') { "Return a URL for a file to be sent to the client. The file will be base64 encoded and embedded in the URL." - bytes <- file.info(file)$size + bytes <- file.size(file) if (is.na(bytes)) return(NULL) diff --git a/R/shinyapp.R b/R/shinyapp.R index 89d08fb0c..804470613 100644 --- a/R/shinyapp.R +++ b/R/shinyapp.R @@ -357,7 +357,7 @@ initAutoReloadMonitor <- function(dir) { files <- sort_c( list.files(dir, pattern = filePattern, recursive = TRUE, ignore.case = TRUE) ) - times <- file.info(files)$mtime + times <- file.mtime(files) names(times) <- files if (is.null(lastValue)) { diff --git a/R/test.R b/R/test.R index bad1bf108..c220c70a0 100644 --- a/R/test.R +++ b/R/test.R @@ -38,7 +38,7 @@ is_legacy_shinytest_dir <- function(path){ } files <- dir(path, full.names = TRUE) - files <- files[!file.info(files)$isdir] + files <- files[!file.info(files, extra_cols = FALSE)$isdir] if (length(files) == 0) { return(FALSE) } diff --git a/R/utils.R b/R/utils.R index e1d5e3d4c..0d4e208b1 100644 --- a/R/utils.R +++ b/R/utils.R @@ -252,7 +252,7 @@ find.file.ci <- function(...) { # The function base::dir.exists was added in R 3.2.0, but for backward # compatibility we need to add this function dirExists <- function(paths) { - file.exists(paths) & file.info(paths)$isdir + file.exists(paths) & file.info(paths, extra_cols = FALSE)$isdir } # Removes empty directory (vectorized). This is needed because file.remove() @@ -803,7 +803,7 @@ cachedFuncWithFile <- function(dir, file, func, case.sensitive = FALSE) { file.path.ci(dir, file) } - now <- file.info(fname)$mtime + now <- file.mtime(fname) autoreload <- last_autoreload < cachedAutoReloadLastChanged$get() if (autoreload || !identical(last_mtime_file, now)) { value <<- func(fname, ...) @@ -1329,7 +1329,7 @@ checkEncoding <- function(file) { # world of consistency (falling back to getOption('encoding') will not help # because native.enc is also normally UTF-8 based on *nix) if (!isWindows()) return('UTF-8') - size <- file.info(file)[, 'size'] + size <- file.info(file, extra_cols = FALSE)[, 'size'] if (is.na(size)) stop('Cannot access the file ', file) # BOM is 3 bytes, so if the file contains BOM, it must be at least 3 bytes if (size < 3L) return('UTF-8') diff --git a/man/reactivePoll.Rd b/man/reactivePoll.Rd index e5cf86ae6..2ba64def8 100644 --- a/man/reactivePoll.Rd +++ b/man/reactivePoll.Rd @@ -63,7 +63,7 @@ function(input, output, session) { # This function returns the time that log_file was last modified checkFunc = function() { if (file.exists(log_file)) - file.info(log_file)$mtime[1] + file.mtime(log_file[1]) else "" }, diff --git a/tests/testthat/test-plot-png.R b/tests/testthat/test-plot-png.R index 54cae7fee..343d70e9f 100644 --- a/tests/testthat/test-plot-png.R +++ b/tests/testthat/test-plot-png.R @@ -1,6 +1,6 @@ test_that("plotPNG()/startPNG() ignores NULL dimensions", { f <- plotPNG(function() plot(1), width = NULL, height = NULL) on.exit(unlink(f)) - bits <- readBin(f, "raw", file.info(f)$size) + bits <- readBin(f, "raw", file.size(f)) expect_gt(length(bits), 0) })