OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4GroupSet Class Reference

#include <C4GroupSet.h>

Collaboration diagram for C4GroupSet:
[legend]

Public Member Functions

bool UnregisterGroup (int32_t iIndex)
 
void Clear ()
 
void Default ()
 
 C4GroupSet ()
 
 C4GroupSet (const C4GroupSet &rCopy)
 
 ~C4GroupSet ()
 
bool RegisterGroup (C4Group &rGroup, bool fOwnGrp, int32_t Priority, int32_t Contents, bool fCheckContent=true)
 
bool RegisterGroups (const C4GroupSet &rCopy, int32_t Contents, const char *szFilename=nullptr, int32_t iMaxSkipID=0)
 
C4GroupFindGroup (int32_t Contents, C4Group *pAfter=nullptr, bool fSamePrio=false)
 
C4GroupFindEntry (const char *szWildcard, int32_t *pPriority=nullptr, int32_t *pID=nullptr)
 
C4GroupFindSuitableFile (const char *szName, const char *const extensions[], char *szFileName, int32_t *pID=nullptr)
 
int32_t GetGroupCount ()
 
C4GroupGetGroup (int32_t iIndex)
 
bool LoadEntry (const char *szEntryName, char **lpbpBuf, size_t *ipSize=nullptr, int32_t iAppendZeros=0)
 
bool LoadEntryString (const char *szEntryName, StdStrBuf *rBuf)
 
bool LoadEntryString (const StdStrBuf &name, StdStrBuf *Buf)
 
C4GroupRegisterParentFolders (const char *szScenFilename)
 
int32_t PreCacheEntries (const char *szEntryMask)
 
int32_t GetLastID ()
 
bool CloseFolders ()
 

Static Public Member Functions

static int32_t CheckGroupContents (C4Group &rGroup, int32_t Contents)
 

Protected Attributes

C4GroupSetNodepFirst
 
C4GroupSetNodepLast
 
int32_t iIndex
 

Friends

class C4GroupSetNode
 

Detailed Description

Definition at line 76 of file C4GroupSet.h.

Constructor & Destructor Documentation

C4GroupSet::C4GroupSet ( )

Definition at line 66 of file C4GroupSet.cpp.

References Default(), and iIndex.

67 {
68  // zero fields
69  Default();
70  iIndex=0;
71 }
void Default()
Definition: C4GroupSet.cpp:57
int32_t iIndex
Definition: C4GroupSet.h:80

Here is the call graph for this function:

C4GroupSet::C4GroupSet ( const C4GroupSet rCopy)

Definition at line 73 of file C4GroupSet.cpp.

References C4GSCnt_All, Default(), iIndex, and RegisterGroups().

74 {
75  // zero fields
76  Default();
77  iIndex=0;
78  // copy from other group set
80 }
void Default()
Definition: C4GroupSet.cpp:57
bool RegisterGroups(const C4GroupSet &rCopy, int32_t Contents, const char *szFilename=nullptr, int32_t iMaxSkipID=0)
Definition: C4GroupSet.cpp:128
#define C4GSCnt_All
Definition: C4GroupSet.h:51
int32_t iIndex
Definition: C4GroupSet.h:80

Here is the call graph for this function:

C4GroupSet::~C4GroupSet ( )

Definition at line 82 of file C4GroupSet.cpp.

References Clear().

83 {
84  // clear nodes
85  Clear();
86 }
void Clear()
Definition: C4GroupSet.cpp:50

Here is the call graph for this function:

Member Function Documentation

int32_t C4GroupSet::CheckGroupContents ( C4Group rGroup,
int32_t  Contents 
)
static

Definition at line 106 of file C4GroupSet.cpp.

References C4CFN_DefFiles, C4CFN_FontFiles, C4CFN_Graphics, C4CFN_Material, C4CFN_Music, C4GSCnt_Definitions, C4GSCnt_FontDefs, C4GSCnt_Graphics, C4GSCnt_Loaders, C4GSCnt_Material, C4GSCnt_Music, and C4Group::FindEntry().

Referenced by C4GameResList::LoadFoldersWithLocalDefs(), and RegisterGroup().

107 {
108  // update mask
109  if (Contents & C4GSCnt_Graphics) if (!rGroup.FindEntry(C4CFN_Graphics)) Contents=Contents&~C4GSCnt_Graphics;
110  if (Contents & C4GSCnt_Loaders)
111  {
112  if (!rGroup.FindEntry("Loader*.bmp")
113  && !rGroup.FindEntry("Loader*.png")
114  && !rGroup.FindEntry("Loader*.jpg")
115  && !rGroup.FindEntry("Loader*.jpeg"))
116  {
117  Contents=Contents&~C4GSCnt_Loaders;
118  }
119  }
120  if (Contents & C4GSCnt_Material) if (!rGroup.FindEntry(C4CFN_Material)) Contents=Contents&~C4GSCnt_Material;
121  if (Contents & C4GSCnt_Music) if (!rGroup.FindEntry(C4CFN_Music)) Contents=Contents&~C4GSCnt_Music;
122  if (Contents & C4GSCnt_Definitions) if (!rGroup.FindEntry(C4CFN_DefFiles)) Contents=Contents&~C4GSCnt_Definitions;
123  if (Contents & C4GSCnt_FontDefs) if (!rGroup.FindEntry(C4CFN_FontFiles)) Contents=Contents&~C4GSCnt_FontDefs;
124  // return it
125  return Contents;
126 }
bool FindEntry(const char *szWildCard, StdStrBuf *sFileName=nullptr, size_t *iSize=nullptr)
Definition: C4Group.cpp:1774
#define C4GSCnt_FontDefs
Definition: C4GroupSet.h:39
#define C4CFN_Material
Definition: C4Components.h:25
#define C4GSCnt_Material
Definition: C4GroupSet.h:36
#define C4GSCnt_Definitions
Definition: C4GroupSet.h:38
#define C4GSCnt_Graphics
Definition: C4GroupSet.h:34
#define C4GSCnt_Loaders
Definition: C4GroupSet.h:35
#define C4CFN_FontFiles
Definition: C4Components.h:182
#define C4CFN_Music
Definition: C4Components.h:30
#define C4CFN_Graphics
Definition: C4Components.h:28
#define C4CFN_DefFiles
Definition: C4Components.h:166
#define C4GSCnt_Music
Definition: C4GroupSet.h:37

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GroupSet::Clear ( )

Definition at line 50 of file C4GroupSet.cpp.

References pFirst.

Referenced by C4Language::Clear(), C4Game::Clear(), C4GraphicsResource::CloseFiles(), and ~C4GroupSet().

51 {
52  // clear nodes
53  while (pFirst) delete pFirst;
54  pFirst = nullptr;
55 }
C4GroupSetNode * pFirst
Definition: C4GroupSet.h:79

Here is the caller graph for this function:

bool C4GroupSet::CloseFolders ( )

Definition at line 235 of file C4GroupSet.cpp.

References C4GSPrio_Folder, C4GSPrio_Folder2, C4GSPrio_Scenario, and pFirst.

Referenced by C4Game::CloseScenario().

236 {
237  // close everything that has folder-priority
238  for (C4GroupSetNode *pNode=pFirst,*pNext; pNode; pNode=pNext)
239  {
240  // get next, as pNode might be destroyed
241  pNext=pNode->pNext;
242  // check if priority matches
243  if (Inside<int32_t>(pNode->Priority, C4GSPrio_Folder, C4GSPrio_Folder2) || pNode->Priority==C4GSPrio_Scenario)
244  // clear it!
245  delete pNode;
246  }
247  // done, success
248  return true;
249 }
#define C4GSPrio_Scenario
Definition: C4GroupSet.h:31
C4GroupSetNode * pFirst
Definition: C4GroupSet.h:79
#define C4GSPrio_Folder
Definition: C4GroupSet.h:29
#define C4GSPrio_Folder2
Definition: C4GroupSet.h:30

Here is the caller graph for this function:

void C4GroupSet::Default ( )

Definition at line 57 of file C4GroupSet.cpp.

References pFirst, and pLast.

Referenced by C4GroupSet(), and C4Game::Default().

58 {
59  // zero fields
60  pFirst=pLast=nullptr;
61  // do not reset index here, because group set IDs are meant to be unique
62  // for each instance of the engine
63  // see also C4GraphicsResource::RegisterGlobalGraphics
64 }
C4GroupSetNode * pLast
Definition: C4GroupSet.h:79
C4GroupSetNode * pFirst
Definition: C4GroupSet.h:79

Here is the caller graph for this function:

C4Group * C4GroupSet::FindEntry ( const char *  szWildcard,
int32_t *  pPriority = nullptr,
int32_t *  pID = nullptr 
)

Definition at line 175 of file C4GroupSet.cpp.

References pFirst, and C4GroupSetNode::pNext.

Referenced by FindSuitableFile(), C4AchievementGraphics::Init(), C4ComponentHost::Load(), C4Surface::LoadAny(), LoadEntry(), and LoadEntryString().

176 {
177  // find group that has this entry
178  for (C4GroupSetNode *pNode=pFirst; pNode; pNode=pNode->pNext)
179  if (pNode->pGroup->FindEntry(szWildcard))
180  {
181  // assign priority and ID, if ptrs is given
182  if (pPriority) *pPriority=pNode->Priority;
183  if (pID) *pID=pNode->id;
184  // return found group
185  return pNode->pGroup;
186  }
187  // nothing found
188  return nullptr;
189 }
C4GroupSetNode * pFirst
Definition: C4GroupSet.h:79
C4GroupSetNode * pNext
Definition: C4GroupSet.h:58

Here is the caller graph for this function:

C4Group * C4GroupSet::FindGroup ( int32_t  Contents,
C4Group pAfter = nullptr,
bool  fSamePrio = false 
)

Definition at line 155 of file C4GroupSet.cpp.

References pFirst, and C4GroupSetNode::pNext.

Referenced by C4LoaderScreen::Init(), C4MusicSystem::InitForScenario(), and C4GameResList::Load().

156 {
157  // get priority
158  int32_t iPriority=-1;
159  // find group by matching content mask
160  for (C4GroupSetNode *pNode=pFirst; pNode; pNode=pNode->pNext)
161  {
162  // check contents
163  if (!pAfter && (pNode->Contents & Contents))
164  // check priority
165  if (iPriority==-1 || iPriority==pNode->Priority)
166  // success, found an entry
167  return pNode->pGroup;
168  // find next clear flag
169  if (pNode->pGroup == pAfter) { pAfter=nullptr; if (fSamePrio) iPriority=pNode->Priority; }
170  }
171  // nothing found
172  return nullptr;
173 }
C4GroupSetNode * pFirst
Definition: C4GroupSet.h:79
C4GroupSetNode * pNext
Definition: C4GroupSet.h:58

Here is the caller graph for this function:

C4Group * C4GroupSet::FindSuitableFile ( const char *  szName,
const char *const  extensions[],
char *  szFileName,
int32_t *  pID = nullptr 
)

Definition at line 191 of file C4GroupSet.cpp.

References _MAX_FNAME, EnforceExtension(), FindEntry(), and SCopy().

Referenced by C4FontLoader::InitFont().

192 {
193  C4Group *pGrp = nullptr;
194  C4Group *pGrp2;
195  int iPrio = -1;
196  int32_t iPrio2;
197  int32_t GroupID;
198  char FileName[_MAX_FNAME];
199  SCopy(szName, FileName);
200  for (int i = 0; extensions[i]; ++i)
201  {
202  EnforceExtension(FileName, extensions[i]);
203  pGrp2=FindEntry(FileName, &iPrio2, &GroupID);
204  if ((!pGrp || iPrio2 >= iPrio) && pGrp2)
205  {
206  if (pID) *pID = GroupID;
207  pGrp = pGrp2;
208  SCopy(FileName, szFileName);
209  }
210  }
211  // return found group, if any
212  return pGrp;
213 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
C4Group * FindEntry(const char *szWildcard, int32_t *pPriority=nullptr, int32_t *pID=nullptr)
Definition: C4GroupSet.cpp:175
#define _MAX_FNAME
void EnforceExtension(char *szFilename, const char *szExtension)
Definition: StdFile.cpp:289

Here is the call graph for this function:

Here is the caller graph for this function:

C4Group * C4GroupSet::GetGroup ( int32_t  iIndex)

Definition at line 259 of file C4GroupSet.cpp.

References pFirst, and C4GroupSetNode::pNext.

Referenced by C4Language::CloseGroup(), C4Language::GetPackGroups(), C4Language::Init(), and C4ComponentHost::Load().

260 {
261  // Invalid index
262  if (iIndex < 0)
263  return nullptr;
264  // Find indicated group
265  for (C4GroupSetNode *pNode = pFirst; pNode; pNode = pNode->pNext)
266  if (iIndex == 0)
267  return pNode->pGroup;
268  else
269  iIndex--;
270  // Indicated group not found
271  return nullptr;
272 }
int32_t iIndex
Definition: C4GroupSet.h:80
C4GroupSetNode * pFirst
Definition: C4GroupSet.h:79
C4GroupSetNode * pNext
Definition: C4GroupSet.h:58

Here is the caller graph for this function:

int32_t C4GroupSet::GetGroupCount ( )

Definition at line 251 of file C4GroupSet.cpp.

References pFirst, and C4GroupSetNode::pNext.

Referenced by C4Language::GetPackCount().

252 {
253  int32_t iCount = 0;
254  for (C4GroupSetNode *pNode = pFirst; pNode; pNode = pNode->pNext)
255  iCount++;
256  return iCount;
257 }
C4GroupSetNode * pFirst
Definition: C4GroupSet.h:79
C4GroupSetNode * pNext
Definition: C4GroupSet.h:58

Here is the caller graph for this function:

int32_t C4GroupSet::GetLastID ( )
inline

Definition at line 105 of file C4GroupSet.h.

References iIndex.

Referenced by C4GraphicsResource::RegisterMainGroups().

105 { return iIndex; } // return ID assigned to the last added group
int32_t iIndex
Definition: C4GroupSet.h:80

Here is the caller graph for this function:

bool C4GroupSet::LoadEntry ( const char *  szEntryName,
char **  lpbpBuf,
size_t *  ipSize = nullptr,
int32_t  iAppendZeros = 0 
)

Definition at line 215 of file C4GroupSet.cpp.

References FindEntry(), and C4Group::LoadEntry().

216 {
217  // Load the entry from the first group that has it
218  C4Group *pGroup;
219  if ((pGroup = FindEntry(szEntryName)))
220  return pGroup->LoadEntry(szEntryName, lpbpBuf, ipSize, iAppendZeros);
221  // Didn't find it
222  return false;
223 }
bool LoadEntry(const char *szEntryName, char **lpbpBuf, size_t *ipSize=nullptr, int iAppendZeros=0)
Definition: C4Group.cpp:1893
C4Group * FindEntry(const char *szWildcard, int32_t *pPriority=nullptr, int32_t *pID=nullptr)
Definition: C4GroupSet.cpp:175

Here is the call graph for this function:

bool C4GroupSet::LoadEntryString ( const char *  szEntryName,
StdStrBuf rBuf 
)

Definition at line 225 of file C4GroupSet.cpp.

References FindEntry(), and C4Group::LoadEntryString().

Referenced by C4ComponentHost::Load().

226 {
227  // Load the entry from the first group that has it
228  C4Group *pGroup;
229  if ((pGroup = FindEntry(szEntryName)))
230  return pGroup->LoadEntryString(szEntryName, rBuf);
231  // Didn't find it
232  return false;
233 }
C4Group * FindEntry(const char *szWildcard, int32_t *pPriority=nullptr, int32_t *pID=nullptr)
Definition: C4GroupSet.cpp:175
bool LoadEntryString(const char *szEntryName, StdStrBuf *Buf)
Definition: C4Group.cpp:1932

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GroupSet::LoadEntryString ( const StdStrBuf name,
StdStrBuf Buf 
)
inline

Definition at line 100 of file C4GroupSet.h.

References StdStrBuf::getData(), and LoadEntryString().

Referenced by LoadEntryString().

100 { return LoadEntryString(name.getData(), Buf); }
const char * getData() const
Definition: StdBuf.h:442
bool LoadEntryString(const char *szEntryName, StdStrBuf *rBuf)
Definition: C4GroupSet.cpp:225

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4GroupSet::PreCacheEntries ( const char *  szEntryMask)

Definition at line 375 of file C4GroupSet.cpp.

References pFirst, and C4GroupSetNode::pNext.

Referenced by C4GraphicsResource::Init().

376 {
377  // pre-cache all entries matching mask for packed files in all groups
378  // note this does not catch overloads.
379  int32_t result = 0;
380  for (C4GroupSetNode *pNode = pFirst; pNode; pNode = pNode->pNext)
381  if (pNode->pGroup) result += pNode->pGroup->PreCacheEntries(szEntryMask);
382  return result;
383 }
C4GroupSetNode * pFirst
Definition: C4GroupSet.h:79
C4GroupSetNode * pNext
Definition: C4GroupSet.h:58

Here is the caller graph for this function:

bool C4GroupSet::RegisterGroup ( C4Group rGroup,
bool  fOwnGrp,
int32_t  Priority,
int32_t  Contents,
bool  fCheckContent = true 
)

Definition at line 88 of file C4GroupSet.cpp.

References C4GroupSetNode, CheckGroupContents(), C4GroupSetNode::Contents, iIndex, pLast, C4GroupSetNode::pPrev, and C4GroupSetNode::Priority.

Referenced by C4Language::GetPackGroups(), C4Language::Init(), C4Extra::LoadDef(), C4Game::OpenScenario(), C4GraphicsResource::RegisterGlobalGraphics(), RegisterGroups(), and RegisterParentFolders().

89 {
90  // get node to sort in
91  // begin at back end and search for higher priority
92  C4GroupSetNode *pNode;
93  for (pNode=pLast; pNode; pNode=pNode->pPrev)
94  if (pNode->Priority > Priority) break;
95  // create new node
96  C4GroupSetNode *pNewNode = new C4GroupSetNode(*this, pNode, rGroup, fOwnGrp, ++iIndex);
97  // check content
98  if (fCheckContent) Contents = CheckGroupContents(rGroup, Contents);
99  // set priority and contents mask
100  pNewNode->Priority = Priority;
101  pNewNode->Contents = Contents;
102 
103  return true;
104 }
C4GroupSetNode * pPrev
Definition: C4GroupSet.h:58
C4GroupSetNode * pLast
Definition: C4GroupSet.h:79
int32_t iIndex
Definition: C4GroupSet.h:80
friend class C4GroupSetNode
Definition: C4GroupSet.h:109
int32_t Contents
Definition: C4GroupSet.h:70
int32_t Priority
Definition: C4GroupSet.h:69
static int32_t CheckGroupContents(C4Group &rGroup, int32_t Contents)
Definition: C4GroupSet.cpp:106

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GroupSet::RegisterGroups ( const C4GroupSet rCopy,
int32_t  Contents,
const char *  szFilename = nullptr,
int32_t  iMaxSkipID = 0 
)

Definition at line 128 of file C4GroupSet.cpp.

References C4Group::OpenAsChild(), pFirst, C4GroupSetNode::pNext, and RegisterGroup().

Referenced by C4GroupSet(), C4Language::GetPackGroups(), and C4GraphicsResource::RegisterMainGroups().

129 {
130  // get all groups of rCopy
131  int32_t Contents2;
132  for (C4GroupSetNode *pNode=rCopy.pFirst; pNode; pNode=pNode->pNext)
133  if ((Contents2 = pNode->Contents & Contents))
134  if (pNode->id > iMaxSkipID)
135  {
136  if (!szFilename)
137  // add group but don't check the content again!
138  RegisterGroup(*pNode->pGroup, false, pNode->Priority, Contents2, false);
139  else
140  {
141  // if a filename is given, open the child group
142  C4Group *pGroup = new C4Group();
143  if (!pGroup->OpenAsChild(pNode->pGroup, szFilename))
144  { delete pGroup; continue; }
145  // add the child group to the local list; contents equal Contents2
146  // but this flag is not likely to be used
147  if (!RegisterGroup(*pGroup, true, pNode->Priority, Contents2, false))
148  delete pGroup;
149  }
150  }
151  // done, success
152  return true;
153 }
bool RegisterGroup(C4Group &rGroup, bool fOwnGrp, int32_t Priority, int32_t Contents, bool fCheckContent=true)
Definition: C4GroupSet.cpp:88
C4GroupSetNode * pFirst
Definition: C4GroupSet.h:79
C4GroupSetNode * pNext
Definition: C4GroupSet.h:58
bool OpenAsChild(C4Group *pMother, const char *szEntryName, bool fExclusive=false, bool fCreate=false)
Definition: C4Group.cpp:1585

Here is the call graph for this function:

Here is the caller graph for this function:

C4Group * C4GroupSet::RegisterParentFolders ( const char *  szScenFilename)

Definition at line 294 of file C4GroupSet.cpp.

References _MAX_PATH, C4CFN_FolderFiles, C4GSCnt_Directory, C4GSCnt_Folder, C4GSPrio_Folder, DirectorySeparator, FormatString(), GetExtension(), C4Group::GetName(), GetParentPath(), LoadResStr(), LogFatal(), C4Reloc::Open(), C4Group::OpenAsChild(), RegisterGroup(), Reloc, SCopy(), SEqualNoCase(), SLen(), and WildcardMatch().

Referenced by C4Game::OpenScenario().

295 {
296  // the scenario filename may be a scenario or directly a group folder
297  C4Group *pParentGroup=nullptr; bool fParentC4F;
298  char szParentfolder[_MAX_PATH+1];
299  if (SEqualNoCase(GetExtension(szScenFilename), "ocf"))
300  {
301  fParentC4F = true;
302  SCopy(szScenFilename, szParentfolder, _MAX_PATH);
303  }
304  else
305  {
306  GetParentPath(szScenFilename,szParentfolder);
307  fParentC4F = SEqualNoCase(GetExtension(szParentfolder), "ocf");
308  }
309  if (fParentC4F)
310  {
311  // replace all (back)slashes with zero-fields
312  int32_t iOriginalLen=SLen(szParentfolder);
313  for (int32_t i=0; i<iOriginalLen; ++i) if (szParentfolder[i]==DirectorySeparator || szParentfolder[i]=='/') szParentfolder[i]=0;
314  // trace back until the file extension is no more .ocf
315  int32_t iPos=iOriginalLen-1;
316  while (iPos)
317  {
318  // ignore additional zero fields (double-backslashes)
319  while (iPos && !szParentfolder[iPos]) --iPos;
320  // break if end has been reached
321  if (!iPos) break;
322  // trace back until next zero field
323  while (iPos && szParentfolder[iPos]) --iPos;
324  // check extension of this folder
325  if (!SEqualNoCase(GetExtension(szParentfolder+iPos+1), "ocf", 3)) break;
326  // continue
327  }
328  // trace backwards, putting the (back)slashes in place again
329  if (iPos)
330  {
331  szParentfolder[iPos+1+SLen(szParentfolder+iPos+1)]=szParentfolder[iPos]=DirectorySeparator;
332  while (iPos--) if (!szParentfolder[iPos]) szParentfolder[iPos]=DirectorySeparator;
333  ++iPos;
334  }
335  // trace forward again, opening all folders (iPos is 0 again)
336  int32_t iGroupIndex=0;
337  while (iPos<iOriginalLen)
338  {
339  // ignore additional zero-fields
340  while (iPos<iOriginalLen && !szParentfolder[iPos]) ++iPos;
341  // break if end has been reached
342  if (iPos>=iOriginalLen) break;
343  // open this folder
344  C4Group *pGroup = new C4Group();
345  if (pParentGroup)
346  {
347  if (!pGroup->OpenAsChild(pParentGroup, szParentfolder+iPos))
348  {
349  LogFatal(FormatString("%s: %s", LoadResStr("IDS_PRC_FILENOTFOUND"), szParentfolder+iPos).getData());
350  delete pGroup; return nullptr;
351  }
352  }
353  else if (!Reloc.Open(*pGroup, szParentfolder+iPos))
354  {
355  LogFatal(FormatString("%s: %s", LoadResStr("IDS_PRC_FILENOTFOUND"), szParentfolder+iPos).getData());
356  delete pGroup; return nullptr;
357  }
358  // set this group as new parent
359  pParentGroup=pGroup;
360  // add to group set, if this is a true scenario folder
361  int32_t iContentsMask;
362  if (WildcardMatch(C4CFN_FolderFiles, pParentGroup->GetName()))
363  iContentsMask = C4GSCnt_Folder;
364  else
365  iContentsMask = C4GSCnt_Directory;
366  if (!RegisterGroup(*pParentGroup, true, C4GSPrio_Folder+iGroupIndex++, iContentsMask))
367  { delete pParentGroup; LogFatal ("RegGrp: internal error"); return nullptr; }
368  // advance by file name length
369  iPos+=SLen(szParentfolder+iPos);
370  }
371  }
372  return pParentGroup;
373 }
#define C4CFN_FolderFiles
Definition: C4Components.h:176
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
bool RegisterGroup(C4Group &rGroup, bool fOwnGrp, int32_t Priority, int32_t Contents, bool fCheckContent=true)
Definition: C4GroupSet.cpp:88
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:207
#define _MAX_PATH
size_t SLen(const char *sptr)
Definition: Standard.h:74
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool GetParentPath(const char *szFilename, char *szBuffer)
Definition: StdFile.cpp:189
const char * GetName() const
Definition: C4Group.cpp:1845
#define C4GSCnt_Folder
Definition: C4GroupSet.h:43
bool Open(C4Group &hGroup, const char *filename) const
Definition: C4Reloc.cpp:82
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:227
char * GetExtension(char *szFilename)
Definition: StdFile.cpp:121
#define C4GSPrio_Folder
Definition: C4GroupSet.h:29
C4Reloc Reloc
Definition: C4Reloc.cpp:21
bool WildcardMatch(const char *szWildcard, const char *szString)
Definition: StdFile.cpp:374
#define C4GSCnt_Directory
Definition: C4GroupSet.h:45
#define DirectorySeparator
bool OpenAsChild(C4Group *pMother, const char *szEntryName, bool fExclusive=false, bool fCreate=false)
Definition: C4Group.cpp:1585
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GroupSet::UnregisterGroup ( int32_t  iIndex)

Definition at line 274 of file C4GroupSet.cpp.

References pFirst, and C4GroupSetNode::pNext.

Referenced by C4Language::CloseGroup().

275 {
276  // Invalid index
277  if (iIndex < 0)
278  return false;
279  // Find indicated group
280  for (C4GroupSetNode *pNode = pFirst; pNode; pNode = pNode->pNext)
281  if (iIndex == 0)
282  {
283  // Delete found node
284  delete pNode;
285  return true;
286  }
287  else
288  iIndex--;
289  // Indicated group not found
290  return false;
291 
292 }
int32_t iIndex
Definition: C4GroupSet.h:80
C4GroupSetNode * pFirst
Definition: C4GroupSet.h:79
C4GroupSetNode * pNext
Definition: C4GroupSet.h:58

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4GroupSetNode
friend

Definition at line 109 of file C4GroupSet.h.

Referenced by RegisterGroup().

Member Data Documentation

int32_t C4GroupSet::iIndex
protected

Definition at line 80 of file C4GroupSet.h.

Referenced by C4GroupSet(), GetLastID(), and RegisterGroup().

C4GroupSetNode * C4GroupSet::pLast
protected

The documentation for this class was generated from the following files: