Skip to content

Commit

Permalink
os: add behavior info to is_dir_empty documentation (#14110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Larpon committed Apr 21, 2022
1 parent 26b0e7f commit 506259a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions vlib/os/os.v
Expand Up @@ -162,6 +162,7 @@ pub fn rmdir_all(path string) ? {
}

// is_dir_empty will return a `bool` whether or not `path` is empty.
// Note that it will return `true` if `path` does not exist.
[manualfree]
pub fn is_dir_empty(path string) bool {
items := ls(path) or { return true }
Expand Down
6 changes: 6 additions & 0 deletions vlib/os/os_test.v
Expand Up @@ -355,6 +355,12 @@ fn test_mv() {
assert !os.is_dir(expected)
}

fn test_is_dir_empty() {
// Test that is_dir_empty returns true on
// non-existent directories ***as stated in it's doc string***
assert os.is_dir_empty('dir that does not exist at all')
}

fn test_cp_all() {
// fileX -> dir/fileX
// Note: clean up of the files happens inside the cleanup_leftovers function
Expand Down

0 comments on commit 506259a

Please sign in to comment.