tests/findFiles.R

message("Testing findFiles()...")

library("R.utils")

path <- system.file(".", package="R.utils")

pathname <- findFiles(paths=path, firstOnly=TRUE)
print(pathname)

pathnames <- findFiles(paths=path, firstOnly=FALSE)
str(pathnames)

pathnames <- findFiles(paths=path, recursive=TRUE, firstOnly=FALSE)
str(pathnames)

pathnames <- findFiles(pattern="[.]rds$", paths=path, recursive=TRUE, firstOnly=FALSE)
str(pathnames)


## Recursive searching
pathnames0 <- findFiles(paths=path, recursive=FALSE, firstOnly=FALSE)
str(pathnames)

pathnames <- findFiles(paths=path, recursive=0L, firstOnly=FALSE)
str(pathnames)
stopifnot(identical(pathnames, pathnames0))

pathnamesInf <- findFiles(paths=path, recursive=TRUE, firstOnly=FALSE)
str(pathnamesInf)
stopifnot(length(pathnamesInf) >= length(pathnames0))

pathnames <- findFiles(paths=path, recursive=+Inf, firstOnly=FALSE)
str(pathnames)
stopifnot(identical(pathnames, pathnamesInf))

pathnames2 <- findFiles(paths=path, recursive=2L, firstOnly=FALSE)
str(pathnames2)
stopifnot(length(pathnames2) >= length(pathnames0))
stopifnot(length(pathnames2) <= length(pathnamesInf))


message("Testing findFiles()...DONE")
HenrikBengtsson/R.utils documentation built on March 7, 2024, 9:37 a.m.