Helper function for checking given suffix on path

This commit is contained in:
Panu Matilainen 2008-01-27 16:00:06 +02:00
parent c63f859b78
commit f0f392cce6
2 changed files with 16 additions and 0 deletions

View File

@ -863,3 +863,11 @@ char * rpmEscapeSpaces(const char * s)
*te = '\0';
return t;
}
int rpmFileHasSuffix(const char *path, const char *suffix)
{
size_t plen = strlen(path);
size_t slen = strlen(suffix);
return (plen >= slen &&
strcmp(path+plen-slen, suffix) == 0);
}

View File

@ -110,4 +110,12 @@ int rpmGlob(const char * patterns, int * argcPtr, char *** argvPtr);
*/
char * rpmEscapeSpaces(const char * s);
/**
* Check if path (string) ends with given suffix
* @param path (path) string
* @param suffix suffix string to check for
* @return 1 if true, 0 otherwise
*/
int rpmFileHasSuffix(const char *path, const char *suffix);
#endif /* _RPMFILEUTIL_H */