summaryrefslogtreecommitdiffstats
path: root/src/cc4group.c
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2020-04-22 18:23:37 +0200
committerMarkus Mittendrein <git@maxmitti.tk>2020-04-22 18:23:37 +0200
commite14cbffbc5fe61337166d962e9a2b6e3bf0ff079 (patch)
tree543a281b38e81eb964243e110fa9f3ca4dbf3097 /src/cc4group.c
parent57915068f2893fa246e1865fcf51cc50a5707189 (diff)
downloadcc4group-e14cbffbc5fe61337166d962e9a2b6e3bf0ff079.tar.gz
cc4group-e14cbffbc5fe61337166d962e9a2b6e3bf0ff079.zip
Fix openAsChild with lazy enabled
Diffstat (limited to 'src/cc4group.c')
-rw-r--r--src/cc4group.c18
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)