# Re: [PATCH v6 2/3] compat: add a basename() compatibility function

1 messages from 2009-05-31 to 2009-05-31. Participants: j.sixt@viscovery.net.
Thread: https://gitlist.dev/t/19612

## j.sixt@viscovery.net, 2009-05-31 08:11

Subject: Re: [PATCH v6 2/3] compat: add a basename() compatibility function
Message-ID: <54809.1243757462@viscovery.net>
URL: https://gitlist.dev/e/54809.1243757462%40viscovery.net

```
On Sun 31/05/09 06:42 , David Aguilar davvid@gmail.com sent:
> On Sat, May 30, 2009 at 09:37:54PM -0700, David Aguilar wrote:
> > Some systems such as Windows lack libgen.h so provide a
> > basename() implementation for cross-platform use.
> > [...]
> > diff --git a/compat/basename.c b/compat/basename.c
> > new file mode 100644
> > index 0000000..c45716a
> > --- /dev/null
> > +++ b/compat/basename.c
> > @@ -0,0 +1,19 @@
> > +#include "../git-compat-util.h"
> > +
> > +/* Adapted from libiberty's basename.c.  */
> > +char *gitbasename (char *path)
> > +{
> > +	const char *base;
> > +
> > +#ifdef USE_WIN32_FS
> > +	/* Skip over the disk name in MSDOS pathnames. */
> > +	if (isalpha(path[0]) && path[1] == ':')
> > +		path += 2;
> > +#endif
> 
> Thanks for bearing through this series everyone.. ;)
> 
> Can someone with better win32 knowledge let me know if the
> USE_WIN32_FS stuff is needed for msysgit?

No, you don't need it: use

	if (has_dos_drive_prefix(path))
		path += 2;

without any #ifdef.

Thank _you_ for going through so many iterations.

Unfortunately, it may take me a day or two until I can test the patches on 
Windows again.

-- Hannes

```
