forked from vieter-v/libvieter
refactor: Package extension now depends on what compression method was detected.
parent
df83bf9fb3
commit
ea852f9102
|
@ -185,11 +185,25 @@ char *vieter_package_to_description(vieter_package *pkg) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// special case for FILENAME
|
// special case for FILENAME
|
||||||
// assuming .pkg.tar.zst; other formats are valid, this should account for
|
char *ext;
|
||||||
// that
|
switch (pkg->compression) {
|
||||||
|
case 0:
|
||||||
|
ext = ".tar";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
ext = ".tar.gz";
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
ext = ".tar.xz";
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
ext = ".tar.zst";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
size_to_be_written =
|
size_to_be_written =
|
||||||
snprintf(aux, small_buff_size, "%%FILENAME%%\n%s-%s-%s.pkg.tar.zst",
|
snprintf(aux, small_buff_size, "%%FILENAME%%\n%s-%s-%s.pkg%s",
|
||||||
pkg_info->name, pkg_info->version, pkg_info->arch);
|
pkg_info->name, pkg_info->version, pkg_info->arch, ext);
|
||||||
|
|
||||||
// We neither want to let an arbritrarily long input to overflow the buffer
|
// We neither want to let an arbritrarily long input to overflow the buffer
|
||||||
// nor to truncate perfectly valid inputs
|
// nor to truncate perfectly valid inputs
|
||||||
|
|
|
@ -78,6 +78,8 @@ void test_pkg_read_archive_desc() {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
TEST_CHECK(!strcmp(description, desc));
|
TEST_CHECK(!strcmp(description, desc));
|
||||||
|
|
||||||
|
vieter_package_free(&pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_LIST = {
|
TEST_LIST = {
|
||||||
|
|
Loading…
Reference in New Issue