HenrikBengtsson / startup

:wrench: R package: startup - Friendly R Startup Configuration
https://henrikbengtsson.github.io/startup/
160 stars 5 forks source link

check_rprofile_eof() should consider zero length files ok #92

Closed HenrikBengtsson closed 3 years ago

HenrikBengtsson commented 3 years ago

eof_ok() should probably return TRUE for zero length files.

check_rprofile_eof <- function(files = NULL, all = FALSE, fix = TRUE,

backup = TRUE, debug = FALSE) {

eof_ok <- function(file) {

size <- file.info(file)$size

## On Windows, symbolic links give size = 0

if (.Platform$OS.type == "windows" && size == 0L) size <- 1e9

bfr <- readBin(file, what = "raw", n = size)

n <- length(bfr)

if (n == 0L) return(FALSE)

is.element(bfr[n], charToRaw("\n\r"))

}

...
HenrikBengtsson commented 3 years ago

Related to #90

HenrikBengtsson commented 3 years ago

eof_ok() is duplicated in the code