home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Apps / ArchiveUtils / Freeze / basename.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-20  |  1.1 KB  |  36 lines

  1. /* Taken from textutils v1.1 */
  2.  
  3. /* basename.c -- return the last element in a path
  4.    Copyright (C) 1990 Free Software Foundation, Inc.
  5.  
  6.    This program is free software; you can redistribute it and/or modify
  7.    it under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 2, or (at your option)
  9.    any later version.
  10.  
  11.    This program is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License
  17.    along with this program; if not, write to the Free Software
  18.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #if defined(USG) || defined(STDC_HEADERS)
  21. #include <string.h>
  22. #define rindex strrchr
  23. #else
  24. #include <strings.h>
  25. #endif
  26.  
  27. /* Return NAME with any leading path stripped off.  */
  28.  
  29. char *basename (char *name)
  30. {
  31.   char *base;
  32.  
  33.   base = rindex (name, '/');
  34.   return base ? base + 1 : name;
  35. }
  36.