From 3addad2cfa45de0252b63adfa8c3f868076c3f40 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Tue, 21 Apr 2020 01:00:59 +0200 Subject: Add cc4group.isPacked --- src/cc4group.c | 6 ++++++ src/cc4group.h | 4 ++++ src/cppc4group.cpp | 5 +++++ src/cppc4group.hpp | 1 + 4 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/cc4group.c b/src/cc4group.c index 1fc0584..da1ead4 100644 --- a/src/cc4group.c +++ b/src/cc4group.c @@ -3316,6 +3316,11 @@ static bool cc4group_isChild(const CC4Group* const this) return this->parent != NULL; } +static bool cc4group_isPacked(const CC4Group* const this) +{ + return this->root.path != NULL; +} + static const char* cc4group_getName(const CC4Group* const this) { return this->name; @@ -3511,6 +3516,7 @@ CC4Group_API cc4group = { .openAsChild = cc4group_openAsChild, .isChild = cc4group_isChild, + .isPacked = cc4group_isPacked, .getName = cc4group_getName, .getFullName = cc4group_getFullName diff --git a/src/cc4group.h b/src/cc4group.h index 6365f82..51bacbb 100644 --- a/src/cc4group.h +++ b/src/cc4group.h @@ -435,6 +435,10 @@ typedef struct { // NOTE: this function can't fail, thus the return value is the result value, not the success indication bool (*isChild)(const CC4Group* const this); + // returns wether this group is packed or loaded from a normal directory + // NOTE: this function can't fail, thus the return value is the result value, not the success indication + bool (*isPacked)(const CC4Group* const this); + // returns the filename of the group file, if known, or directory name of the child-root entry for openAsChild groups // might return NULL if not determinable (e.g. if not opened from file) diff --git a/src/cppc4group.cpp b/src/cppc4group.cpp index d2a2245..7249854 100644 --- a/src/cppc4group.cpp +++ b/src/cppc4group.cpp @@ -493,6 +493,11 @@ bool CppC4Group::isChild() const return cc4group.isChild(p->g); } +bool CppC4Group::isPacked() const +{ + return cc4group.isPacked(p->g); +} + std::string CppC4Group::getName() const { std::string ret; diff --git a/src/cppc4group.hpp b/src/cppc4group.hpp index d80ffdf..346e8cb 100644 --- a/src/cppc4group.hpp +++ b/src/cppc4group.hpp @@ -194,6 +194,7 @@ public: // to get the child group out of the optional in case of success, construct a new CppC4Group with the move constructor: CppC4Group child{std::move(*optionalChild)}; std::optional openAsChild(const std::string& path); bool isChild() const; + bool isPacked() const; std::string getName() const; std::string getFullName() const; -- cgit v1.2.3-54-g00ecf