Project

General

Profile

Actions

Feature #10121

closed

Dir.empty?

Added by shevegen (Robert A. Heiler) over 9 years ago. Updated almost 8 years ago.

Status:
Closed
Target version:
-
[ruby-core:64291]

Description

On IRC someone asked how to find out if a directory is empty or not, from within ruby.

It seems as if there was no simple way.

I suggest adding Dir.empty?

On IRC, someone else suggested this:

Dir.entries(dir).size == 2

I do not know if there are better ways but possibly that could
be used for a Dir.empty? functionality?


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #12010: Exclude dot and dotdot from Dir#eachClosedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0