Poss Bug: FileTest.exists? ("") returns true on Windows

I just caught by something.

Under Cygwin with a version of 1.73 I checked out a couple of weeks ago,
if I do “FileTest.exists?(”")" in irb I get false. However using the
native windows version (Windows Installer v1.73-7), in irb the return is
true.

I assume this is a bug, but I just want to be sure :slight_smile:

Microsoft Windows XP [Version 5.1.2600]
© Copyright 1985-2001 Microsoft Corp.

I:\Documents and Settings\robertm>irb
irb(main):001:0> FileTest.exists?("")
true
irb(main):002:0>

robertm@CLEMFAR ~
$ irb
irb(main):001:0> FileTest.exists?("")
false
irb(main):002:0> exit

-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----

Hi,

···

At Sun, 1 Dec 2002 08:40:45 +0900, Robert McGovern wrote:

Under Cygwin with a version of 1.73 I checked out a couple of weeks
ago, if I do “FileTest.exists?(”“)” in irb I get false. However using
the native windows version (Windows Installer v1.73-7), in irb the
return is true.

I assume this is a bug, but I just want to be sure :slight_smile:

It would be a bug, and ENOENT rather than EBADF should be
returned for invalid path, I guess.

Index: win32.c

RCS file: /cvs/ruby/src/ruby/win32/win32.c,v
retrieving revision 1.73
diff -u -2 -p -r1.73 win32.c
— win32.c 12 Oct 2002 14:47:07 -0000 1.73
+++ win32.c 1 Dec 2002 05:31:13 -0000
@@ -2540,11 +2540,10 @@ rb_w32_stat(const char *path, struct sta
}
*s = ‘\0’;

  • len = strlen(buf1);
  • p = CharPrev(buf1, buf1 + len);
  • if( ‘"’ == *(–s) )
  • {
  • errno = EBADF;
  • len = s - buf1;

  • if (!len || ‘"’ == *(–s)) {

  • errno = ENOENT;
    return -1;
    }

  • p = CharPrev(buf1, buf1 + len);

    if (isUNCRoot(buf1)) {


Nobu Nakada

Hi,

···

In message “Re: Poss Bug: FileTest.exists? (”“) returns true on Windows” on 02/12/01, nobu.nokada@softhome.net nobu.nokada@softhome.net writes:

It would be a bug, and ENOENT rather than EBADF should be
returned for invalid path, I guess.

Commit the fix, please,

						matz.

Under Cygwin with a version of 1.73 I checked out a couple of weeks
ago, if I do “FileTest.exists?(”“)” in irb I get false. However using
the native windows version (Windows Installer v1.73-7), in irb the
return is true.

I assume this is a bug, but I just want to be sure :slight_smile:

It would be a bug, and ENOENT rather than EBADF should be
returned for invalid path, I guess.

Cool, many thanks for fixing it :slight_smile:

Rob

-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----