perf: skip redundant mkdir_p in funpack for entries without subdirectories
This commit is contained in:
+5
-4
@@ -126,19 +126,20 @@ static int extract_entry(const char *out_dir, const fpk_entry_t *entry,
|
||||
const void *data, size_t size)
|
||||
{
|
||||
char *full_path = join_path(out_dir, entry->path);
|
||||
char *dir_part = dup_str(full_path);
|
||||
char *slash = strrchr(dir_part, '/');
|
||||
FILE *fp;
|
||||
|
||||
if (slash) {
|
||||
if (strchr(entry->path, '/') != NULL) {
|
||||
char *dir_part = dup_str(full_path);
|
||||
char *slash = strrchr(dir_part, '/');
|
||||
|
||||
*slash = '\0';
|
||||
if (!mkdir_p(dir_part)) {
|
||||
free(dir_part);
|
||||
free(full_path);
|
||||
return 0;
|
||||
}
|
||||
free(dir_part);
|
||||
}
|
||||
free(dir_part);
|
||||
|
||||
fp = fopen(full_path, "wb");
|
||||
if (!fp) {
|
||||
|
||||
Reference in New Issue
Block a user