Helper function for checking given suffix on path
authorPanu Matilainen <pmatilai@redhat.com>
Sun, 27 Jan 2008 14:00:06 +0000 (16:00 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Sun, 27 Jan 2008 14:00:06 +0000 (16:00 +0200)
rpmio/rpmfileutil.c
rpmio/rpmfileutil.h

index b07c93a..e3ff9ee 100644 (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);
+}
index bd45d18..ee90514 100644 (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 */