Issue #16249 has been updated by shevegen (Robert A. Heiler).


Personally I think I have wanted/needed this in the past. It has not been
that important to me to suggest it myself, though, but +1 on the name/API.

I guess it may have to do with what is/should be possible through FileUtils.
We already do have a few file-related activities outside of FileUtils,
though, such as File.delete(). I use the latter a lot, more often than
tapping into FileUtils (if the task is to delete the file); oddly enough,
one minor reason is that I can avoid having to do require 'fileutils',
a bit similar as to how I like how require 'pp' became optional - but
anyway, I digress, so +1 to the suggestion in itself.

(I have no particular opinion on the implementation either way; my comment
here is really meant to the Dir.empty?() and File.empty?() API/suggestion
alone.)

----------------------------------------
Feature #16249: Dir#empty? and File#empty?
https://bugs.ruby-lang.org/issues/16249#change-81991

* 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>