Bug #449
closedFile.zero? returns true when given a directory on Windows
Description
=begin
On Mac OS X File.zero? returns false when given a directory.
=end
Updated by nobu (Nobuyoshi Nakada) about 16 years ago
=begin
Hi,
At Sat, 16 Aug 2008 06:35:31 +0900,
Anonymous wrote in [ruby-core:18314]:
Bug #449: File.zero? returns true when given a directory on Windows
On Mac OS X File.zero? returns false when given a directory.
It is very file-system dependent behavior, and the result has
no meaning on any systems.
On unix-like systems, size of properly created directory can
never be 0, since there are "." and ".." always.
`properly' means it is created with mkdir system call, but¶
not mknod syscall by root.¶
On the other hand, Windows claims "size of a directory always
must be 0".
--
Nobu Nakada
=end
Updated by nobu (Nobuyoshi Nakada) about 16 years ago
- Status changed from Open to Rejected
=begin
=end
Updated by luislavena (Luis Lavena) about 16 years ago
=begin
On Mon, Aug 18, 2008 at 8:08 PM, Nobuyoshi Nakada nobu@ruby-lang.org wrote:
Hi,
At Tue, 19 Aug 2008 02:07:03 +0900,
Luis Lavena wrote in [ruby-core:18328]:File.zero? always return false when a Directory is being requested
(*nix), so similar thinking on Windows will reduce the surprise
factor, right?File.zero? isn't the real issue. I can't imagine why you want
to use File.size for a directory. It is a just garbage, I
think. In what case is it usable?
Don't look at me, I never thought about using it that way, but if
someone reported it maybe someone is using it wrongly?
Also the File.zero? documentation can be updated to reflect that
File.zero? is not reliable across platforms given the same scenario.May Dir#empty? or something else be "expected" method?
If this bug report came from the RubySpec, then the expectations are
bad... and the documentation can reflect this.
--
Luis Lavena
AREA 17
Human beings, who are almost unique in having the ability to learn from
the experience of others, are also remarkable for their apparent
disinclination to do so.
Douglas Adams
=end
Updated by matz (Yukihiro Matsumoto) about 16 years ago
=begin
Hi,
In message "Re: [ruby-core:18325] Re: [Bug #449] File.zero? returns true when given a directory on Windows"
on Tue, 19 Aug 2008 00:43:35 +0900, "John Lam (IRONRUBY)" jflam@microsoft.com writes:
|
|I submitted that original bug (first time using redmine :)). Here's some more context:
|
|File.zero? on Windows when given a directory name produces a nonsensical result. It should do one of the following:
|
|1) Provide consistent results given a directory name on both Windows and *nix
|2) Throw an exception since File != Directory
|
|Since 2) is not the Ruby Way, it makes more sense to either do 1), or mark its behavior as "undefined", or "platform specific" which will let individual implementations decide how to define it.
|
|Does this sound reasonable to folks?
Currently we define its behavior as "platform specific". Any
objection?
matz.
=end
Updated by luislavena (Luis Lavena) about 16 years ago
=begin
On Mon, Aug 18, 2008 at 6:45 PM, John Lam (IRONRUBY)
jflam@microsoft.com wrote:
Not at all - it means we're now free to do the right thing :)
I hope by "the right thing" you don't say "raise an exception" as the
ideal option ;-)
File.zero? always return false when a Directory is being requested
(*nix), so similar thinking on Windows will reduce the surprise
factor, right?
Also the File.zero? documentation can be updated to reflect that
File.zero? is not reliable across platforms given the same scenario.
Thanks,
-John
Regards,¶
Luis Lavena
AREA 17
Human beings, who are almost unique in having the ability to learn from
the experience of others, are also remarkable for their apparent
disinclination to do so.
Douglas Adams
=end
Updated by nobu (Nobuyoshi Nakada) about 16 years ago
=begin
Hi,
At Tue, 19 Aug 2008 02:07:03 +0900,
Luis Lavena wrote in [ruby-core:18328]:
File.zero? always return false when a Directory is being requested
(*nix), so similar thinking on Windows will reduce the surprise
factor, right?
File.zero? isn't the real issue. I can't imagine why you want
to use File.size for a directory. It is a just garbage, I
think. In what case is it usable?
Also the File.zero? documentation can be updated to reflect that
File.zero? is not reliable across platforms given the same scenario.
May Dir#empty? or something else be "expected" method?
--
Nobu Nakada
=end