Skip to content

Commit d2657f8

Browse files
authored
Merge pull request #472 from tin900/main
2 parents 98af389 + 81ad85e commit d2657f8

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export(fs_perms)
6969
export(group_ids)
7070
export(is_absolute_path)
7171
export(is_dir)
72+
export(is_dir_empty)
7273
export(is_file)
7374
export(is_file_empty)
7475
export(is_link)

R/is.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,24 @@ is_absolute_path <- function(path) {
6565
tidy_path <- path_tidy(path)
6666
grepl("^~", path) | grepl("^(/+|[A-Za-z]:)", tidy_path)
6767
}
68+
69+
#' Check if a directory is empty
70+
#'
71+
#' This function checks whether a given directory is empty or not.
72+
#'
73+
#' @param path A character string specifying the path to the directory to check.
74+
#'
75+
#' @return A logical value. Returns \code{TRUE} if the directory is empty,
76+
#' \code{FALSE} otherwise.
77+
#'
78+
#' @examples
79+
#' \dontrun{
80+
#' is_dir_empty("path/to/empty/directory") # Returns TRUE
81+
#' is_dir_empty("path/to/non-empty/directory") # Returns FALSE
82+
#' }
83+
#'
84+
#' @export
85+
is_dir_empty <- function(path) {
86+
length(dir_ls(path)) == 0
87+
}
88+

_pkgdown.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ reference:
3232
- title: Helpers
3333
contents:
3434
- is_file
35+
- is_dir_empty
3536
- as_fs_path
3637
- as_fs_bytes
3738
- as_fs_perms

man/is_dir_empty.Rd

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)