Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
  2. /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
  3. #include <unistd.h>
  4. #include <libc/unconst.h>
  5.  
  6. char *
  7. basename (const char *fname)
  8. {
  9.   const char *base = fname;
  10.  
  11.   if (fname && *fname)
  12.   {
  13.     if (fname[1] == ':')
  14.     {
  15.       fname += 2;
  16.       base = fname;
  17.     }
  18.  
  19.     while (*fname)
  20.     {
  21.       if (*fname == '\\' || *fname == '/')
  22.         base = fname + 1;
  23.       fname++;
  24.     }
  25.   }
  26.  
  27.   return unconst (base, char *);
  28. }
  29.