[ruby-core:95431] [Ruby master Feature#16249] Dir#empty? and File#empty?
From:
zverok.offline@...
Date:
2019-10-19 12:49:59 UTC
List:
ruby-core #95431
Issue #16249 has been updated by zverok (Victor Shepelev).
@nobu
> This checks a directory named the current `Dir` object opened, instead of the opened directory itself.
I am not sure I understand (probably it is my lack of in-depth filesystem work understanding), for what I can tell, we have a directory object with some path, and check if directory with this path is empty?..
----------------------------------------
Feature #16249: Dir#empty? and File#empty?
https://bugs.ruby-lang.org/issues/16249#change-82183
* Author: zverok (Victor Shepelev)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
I don't think it is a super-valuable addition (as nobody complained about it, or I can't find similar proposals), but seems logical to me:
```ruby
# Existed since 2.4
Dir.empty?('dirname') #=> true/false
File.empty?('filename') # => true/false
# Proposed and implemented:
Dir.open('dirname').empty?
File.open('filename').empty?
```
---Files--------------------------------
file_dir_i_empty.patch (3.27 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>