Skip to content
Snippets Groups Projects
Commit bc72db19 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Speed up list_archive_contents()

Don't use iniSet* since we know we're not updating existing ini entries. Use strListAppendFormat() instead.
parent 8246746b
No related branches found
No related tags found
No related merge requests found
......@@ -764,12 +764,13 @@ str_list_t list_archive_contents(const char* filename, const char* pattern, bool
continue;
}
iniSetString(&list, pathname, "type", type, /* style: */NULL);
iniSetBytes(&list, pathname, "size", 1, archive_entry_size(entry), /* style: */NULL);
iniSetDateTime(&list, pathname, "time", true, archive_entry_mtime(entry), NULL);
iniSetInteger(&list, pathname, "mode", archive_entry_mode(entry), NULL);
iniSetString(&list, pathname, "format", archive_format_name(ar), NULL);
iniSetString(&list, pathname, "compression", archive_filter_name(ar, 0), NULL);
strListAppendFormat(&list, "[%s]", pathname);
strListAppendFormat(&list, "type=%s", type);
strListAppendFormat(&list, "size=%"PRId64, archive_entry_size(entry));
strListAppendFormat(&list, "time=%"PRId64,archive_entry_mtime(entry));
strListAppendFormat(&list, "mode=%d", archive_entry_mode(entry));
strListAppendFormat(&list, "format=%s", archive_format_name(ar));
strListAppendFormat(&list, "compression=%s", archive_filter_name(ar, 0));
if(hash && archive_entry_filetype(entry) == AE_IFREG) {
MD5 md5_ctx;
......@@ -795,10 +796,10 @@ str_list_t list_archive_contents(const char* filename, const char* pattern, bool
}
MD5_close(&md5_ctx, md5);
SHA1Final(&sha1_ctx, sha1);
iniSetHexInt(&list, pathname, "crc32", crc32, NULL);
strListAppendFormat(&list, "crc32=0x%lx", crc32);
char hex[128];
iniSetString(&list, pathname, "md5", MD5_hex(hex, md5), NULL);
iniSetString(&list, pathname, "sha1", SHA1_hex(hex, sha1), NULL);
strListAppendFormat(&list, "md5=%s", MD5_hex(hex, md5));
strListAppendFormat(&list, "sha1=%s", SHA1_hex(hex, sha1));
}
}
archive_read_free(ar);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment