Skip to content

Commit 1012a18

Browse files
authored
Merge pull request #61 from r-lib/f-dir-exists
2 parents 6255965 + 28d35da commit 1012a18

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

R/has-file.R

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ has_file <- function(filepath, contents = NULL, n = -1L) {
2222
if (!file.exists(testfile)) {
2323
return(FALSE)
2424
}
25-
if (is_dir(testfile)) {
25+
if (dir.exists(testfile)) {
2626
return(FALSE)
2727
}
2828
match_contents(testfile, .(contents), .(n))
@@ -52,10 +52,7 @@ has_dir <- function(filepath) {
5252

5353
testfun <- eval(bquote(function(path) {
5454
testfile <- file.path(path, .(filepath))
55-
if (!file.exists(testfile)) {
56-
return(FALSE)
57-
}
58-
is_dir(testfile)
55+
dir.exists(testfile)
5956
}))
6057

6158
desc <- paste0("contains a directory `", filepath, "`")
@@ -263,15 +260,11 @@ str.root_criteria <- function(object, ...) {
263260

264261
list_files <- function(path, filename) {
265262
files <- dir(path = path, pattern = filename, all.files = TRUE, full.names = TRUE)
266-
dirs <- is_dir(files)
263+
dirs <- dir.exists(files)
267264
files <- files[!dirs]
268265
files
269266
}
270267

271-
is_dir <- function(x) {
272-
dir.exists(x)
273-
}
274-
275268
match_contents <- function(f, contents, n) {
276269
if (is.null(contents)) {
277270
return(TRUE)

0 commit comments

Comments
 (0)