[Win32utils-devel] File.basename issue

Park Heesob phasis at nownuri.net
Fri Aug 19 21:04:58 EDT 2005

Hi Dan,

> Hi all,
> After a recent ruby-talk thread I decided to go back and refactor the
> File.basename method in win32-file.  Sure enough, after a I added some
> more tests I discovered a couple minor bugs.
> After reworking it, I still can't get one test to pass.  Specifically,
> multiple trailing slashes.  Here's the test that shows the issue:
> assert_equal("bar", File.basename("C:/foo/bar\\\\"))
> Instead of "bar", I end up with "bar\" because I only call
> PathRemoveBackslash() once.  I figured I could solve it with something
> like this:
> while(PathRemoveBackslash(path)){}
> But that doesn't work.  I thought you could just call this until you hit
> NULL, but I can't seem to make it work.  I suspect the answer is easy,
> I'm just not seeing it for some reason.
> Ideas?
> Dan
The msdn document reads
  Returns the address of the NULL that replaced the backslash, or the 
address of the last character if it's not a backslash.


You should use



Park Heesob

More information about the win32utils-devel mailing list