diff options
| -rw-r--r-- | src/cc4group.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/cc4group.c b/src/cc4group.c index 99d4730..981206b 100644 --- a/src/cc4group.c +++ b/src/cc4group.c @@ -2775,8 +2775,8 @@ static bool cc4group_saveParent(CC4Group* const this) static bool cc4group_getEntryInfoForEntry(CC4Group* const this, const C4GroupEntryData* const entry, CC4Group_EntryInfo* const info, bool const lazy) { - C4GroupHeader* header = NULL; - if(entry->core.Directory && !((this->lazy || entry->path != NULL) && lazy)) + C4GroupHeader* header = entry->header; + if(entry->core.Directory && header == NULL && !((this->lazy || entry->path != NULL) && lazy)) { header = cc4group_getHeader(this, entry); if(header == NULL) @@ -2785,15 +2785,17 @@ static bool cc4group_getEntryInfoForEntry(CC4Group* const this, const C4GroupEnt } } + C4GroupHeader* headerOrParentHeader = header != NULL ? header : entry->parent != NULL ? entry->parent->header : NULL; + *info = (CC4Group_EntryInfo){ .fileName = entry->core.FileName, .modified = header != NULL ? header->Creation : entry->core.Modified, - .author = header != NULL ? header->Maker : entry->parent->header->Maker, + .author = headerOrParentHeader != NULL ? headerOrParentHeader->Maker : NULL, .size = header != NULL ? (sizeof(C4GroupHeader) + header->Entries * sizeof(C4GroupEntryCore)) : (size_t)entry->core.Size, .totalSize = entry->core.Size, .executable = entry->core.Executable ? true : false, .directory = entry->core.Directory ? true : false, - .official = C4GroupHeader_isOfficial(header != NULL ? header : entry->parent->header) // parents header is already loaded to access this child + .official = headerOrParentHeader != NULL ? C4GroupHeader_isOfficial(headerOrParentHeader) : false }; return true; @@ -3268,11 +3270,11 @@ static bool cc4group_openAsChildOn(CC4Group* const this, const char* const path, return false; } - memcpy(&child->root.core, &entry->core, sizeof(child->root.core)); - child->root.data = entry->data; - child->root.core.Directory = 1; + GroupEntryList* children = cc4group_getChildren(this, entry); // this also loads the header of entry + child->root = *entry; + child->root.parent = NULL; child->root.core.FileName[0] = '\0'; - child->root.children = cc4group_getChildren(this, entry); + child->root.children = children; child->uncompressedData = this->uncompressedData; if(child->root.children == NULL) |
