virUUIDFormat(def->uuid, uuidstr);
- if (!virFileMatchesNameSuffix(file, uuidstr, ".xml")) {
+ if (!virStringMatchesNameSuffix(file, uuidstr, ".xml")) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("<uuid> does not match secret file name '%s'"),
file);
if (!(def = virStoragePoolDefParseFile(path)))
return NULL;
- if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
+ if (!virStringMatchesNameSuffix(file, def->name, ".xml")) {
virReportError(VIR_ERR_XML_ERROR,
_("Storage pool config filename '%s' does "
"not match pool name '%s'"),
virFileMakeParentPath;
virFileMakePath;
virFileMakePathWithMode;
-virFileMatchesNameSuffix;
virFileMoveMount;
virFileNBDDeviceAssociate;
virFileOpenAs;
virStringListMerge;
virStringListRemove;
virStringMatch;
+virStringMatchesNameSuffix;
virStringParsePort;
virStringReplace;
virStringSearch;
return 0;
}
-int
-virFileMatchesNameSuffix(const char *file,
- const char *name,
- const char *suffix)
-{
- int filelen = strlen(file);
- int namelen = strlen(name);
- int suffixlen = strlen(suffix);
-
- if (filelen == (namelen + suffixlen) &&
- STREQLEN(file, name, namelen) &&
- STREQLEN(file + namelen, suffix, suffixlen))
- return 1;
- else
- return 0;
-}
-
#define SAME_INODE(Stat_buf_1, Stat_buf_2) \
((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
&& (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
int virFileWriteStr(const char *path, const char *str, mode_t mode)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
-int virFileMatchesNameSuffix(const char *file,
- const char *name,
- const char *suffix);
-
int virFileLinkPointsTo(const char *checkLink,
const char *checkDest)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
return 1;
}
+int
+virStringMatchesNameSuffix(const char *file,
+ const char *name,
+ const char *suffix)
+{
+ int filelen = strlen(file);
+ int namelen = strlen(name);
+ int suffixlen = strlen(suffix);
+
+ if (filelen == (namelen + suffixlen) &&
+ STREQLEN(file, name, namelen) &&
+ STREQLEN(file + namelen, suffix, suffixlen))
+ return 1;
+ else
+ return 0;
+}
+
/**
* virStringStripIPv6Brackets:
* @str: the string to strip
const char *suffix);
int virStringStripSuffix(char *str,
const char *suffix) ATTRIBUTE_RETURN_CHECK;
+int virStringMatchesNameSuffix(const char *file,
+ const char *name,
+ const char *suffix);
void virStringStripIPv6Brackets(char *str);
bool virStringHasChars(const char *str,