GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
basename.c
Go to the documentation of this file.
1 
17 #include <grass/gis.h>
18 
19 #include <ctype.h>
20 #include <string.h>
21 
22 
37 char *G_basename(char *filename, const char *desired_ext)
38 {
39  /* Find the last . in the filename */
40  char *dot = strrchr(filename, '.');
41 
42  if (dot && G_strcasecmp(dot + 1, desired_ext) == 0)
43  *dot = '\0';
44 
45  return filename;
46 }
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
Definition: strings.c:192
char * G_basename(char *filename, const char *desired_ext)
Truncates filename to the base part (before the last &#39;.&#39;) if it matches the extension, otherwise leaves it unchanged.
Definition: basename.c:37