Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
packing: add a function to determine if an extension is supported
Baptiste Daroussin committed 5 years ago
commit 6967ed9d40424a10ebb90de06a80e5e7b6dbac3c
parent f849530
2 files changed +15 -0
modified libpkg/packing.c
@@ -448,6 +448,20 @@ packing_format_from_string(const char *str)
	return TXZ;
}

+
bool
+
packing_is_valid_format(const char *str)
+
{
+
	if (str == NULL)
+
		return (false);
+
	if ((strcmp(str, "tzst") == 0) ||
+
	    (strcmp(str, "txz") == 0) ||
+
	    (strcmp(str, "tbz") == 0) ||
+
	    (strcmp(str, "tgz") == 0) ||
+
	    (strcmp(str, "tar") == 0))
+
	    return (true);
+
	return (false);
+
}
+

const char*
packing_format_to_string(pkg_formats format)
{
modified libpkg/private/pkg.h
@@ -790,6 +790,7 @@ void packing_get_filename(struct packing *pack, const char *filename);
void packing_finish(struct packing *pack);
pkg_formats packing_format_from_string(const char *str);
const char* packing_format_to_string(pkg_formats format);
+
bool packing_is_valid_format(const char *str);

int pkg_delete_files(struct pkg *pkg, unsigned force);
int pkg_delete_dirs(struct pkgdb *db, struct pkg *pkg, struct pkg *p);