OpenClonk
C4Group.cpp File Reference
#include "C4Include.h"
#include "c4group/C4Group.h"
#include "c4group/C4Components.h"
#include "lib/C4InputValidation.h"
#include <zlib.h>
Include dependency graph for C4Group.cpp:

Go to the source code of this file.

Classes

struct  C4Group::P
 

Functions

void C4Group_SetProcessCallback (bool(*callback)(const char *, int))
 
void C4Group_SetSortList (const char **sort_list)
 
void C4Group_SetTempPath (const char *path)
 
const char * C4Group_GetTempPath ()
 
bool C4Group_TestIgnore (const char *filename)
 
bool C4Group_IsGroup (const char *filename)
 
bool C4Group_CopyItem (const char *source, const char *target, bool no_sorting, bool reset_attributes)
 
bool C4Group_MoveItem (const char *source, const char *target, bool no_sorting)
 
bool C4Group_DeleteItem (const char *item_name, bool do_recycle)
 
bool C4Group_PackDirectoryTo (const char *filename, const char *to_filename)
 
bool C4Group_PackDirectory (const char *filename)
 
bool C4Group_UnpackDirectory (const char *filename)
 
bool C4Group_ExplodeDirectory (const char *filename)
 
bool C4Group_ReadFile (const char *filename, char **data, size_t *size)
 
void MemScramble (BYTE *buffer, int size)
 
bool C4Group_IsExcluded (const char *filename, const char *exclude_list)
 
int SortRank (const char *element, const char *sort_list)
 

Variables

const char * C4CFN_FLS []
 
char C4Group_TempPath [_MAX_PATH_LEN] = ""
 
char C4Group_Ignore [_MAX_PATH_LEN] ="cvs;CVS;Thumbs.db;.orig;.svn"
 
const char ** C4Group_SortList = nullptr
 
bool(* C4Group_ProcessCallback )(const char *, int) = nullptr
 

Function Documentation

◆ C4Group_CopyItem()

bool C4Group_CopyItem ( const char *  source,
const char *  target,
bool  no_sorting,
bool  reset_attributes 
)

Definition at line 115 of file C4Group.cpp.

116 {
117  // Parameter check
118  if (!source || !target || !source[0] || !target[0])
119  {
120  return false;
121  }
122  char target_path[_MAX_PATH_LEN];
123  SCopy(target, target_path, _MAX_PATH);
124 
125  // Backslash terminator indicates target is a path only (append filename)
126  if (target_path[SLen(target_path) - 1] == DirectorySeparator)
127  {
128  SAppend(GetFilename(source), target_path);
129  }
130 
131  // Check for identical source and target
132  // Note that attributes aren't reset here
133  if (ItemIdentical(source, target_path))
134  {
135  return true;
136  }
137 
138  // Source and target are simple items
139  if (ItemExists(source) && CreateItem(target_path))
140  {
141  return CopyItem(source, target_path, reset_attributes);
142  }
143 
144  // For items within groups, attribute resetting isn't needed, because packing/unpacking will kill all
145  // attributes anyway
146 
147  // Source & target
148  C4Group source_parent;
149  C4Group target_parent;
150  char source_parent_path[_MAX_PATH_LEN];
151  char target_parent_path[_MAX_PATH_LEN];
152  GetParentPath(source, source_parent_path);
153  GetParentPath(target_path, target_parent_path);
154 
155  // Temp filename
156  char temp_filename[_MAX_PATH_LEN];
157  SCopy(C4Group_TempPath, temp_filename, _MAX_PATH);
158  SAppend(GetFilename(source), temp_filename);
159  MakeTempFilename(temp_filename);
160 
161  // Extract source to temp file
162  if ( !source_parent.Open(source_parent_path)
163  || !source_parent.Extract(GetFilename(source), temp_filename)
164  || !source_parent.Close())
165  {
166  return false;
167  }
168 
169  // Move temp file to target
170  if ( !target_parent.Open(target_parent_path)
171  || !target_parent.SetNoSort(no_sorting)
172  || !target_parent.Move(temp_filename, GetFilename(target_path))
173  || !target_parent.Close())
174  {
175  EraseItem(temp_filename);
176  return false;
177  }
178 
179  return true;
180 }
char C4Group_TempPath[_MAX_PATH_LEN]
Definition: C4Group.cpp:59
#define DirectorySeparator
#define _MAX_PATH
#define _MAX_PATH_LEN
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
void SAppend(const char *szSource, char *szTarget, int iMaxL)
Definition: Standard.cpp:263
size_t SLen(const char *sptr)
Definition: Standard.h:74
bool EraseItem(const char *szItemName)
Definition: StdFile.cpp:833
bool CreateItem(const char *szItemname)
Definition: StdFile.cpp:839
bool GetParentPath(const char *szFilename, char *szBuffer)
Definition: StdFile.cpp:186
void MakeTempFilename(char *szFilename)
Definition: StdFile.cpp:320
bool ItemIdentical(const char *szFilename1, const char *szFilename2)
Definition: StdFile.cpp:879
char * GetFilename(char *szPath)
Definition: StdFile.cpp:42
bool CopyItem(const char *szSource, const char *szTarget, bool fResetAttributes)
Definition: StdFile.cpp:855
bool ItemExists(const char *szItemName)
Definition: StdFile.h:75
bool Extract(const char *files, const char *destination=nullptr, const char *exclude=nullptr)
Definition: C4Group.cpp:1808
bool SetNoSort(bool no_sorting)
Definition: C4Group.cpp:2552
bool Close()
Definition: C4Group.cpp:971
bool Move(const char *filename, const char *entry_name)
Definition: C4Group.cpp:1633
bool Open(const char *group_name, bool do_create=false)
Definition: C4Group.cpp:660

References _MAX_PATH, _MAX_PATH_LEN, C4Group_TempPath, C4Group::Close(), CopyItem(), CreateItem(), DirectorySeparator, EraseItem(), C4Group::Extract(), GetFilename(), GetParentPath(), ItemExists(), ItemIdentical(), MakeTempFilename(), C4Group::Move(), C4Group::Open(), SAppend(), SCopy(), C4Group::SetNoSort(), and SLen().

Referenced by C4Network2Res::Derive(), C4MusicFile::ExtractFile(), C4Network2Res::GetStandalone(), C4Network2Res::OptimizeStandalone(), C4ControlJoinPlayer::PreRec(), C4MessageInput::ProcessCommand(), C4Network2::RetrieveScenario(), C4Player::Save(), C4PlayerList::Save(), C4Console::SaveScenario(), and C4Playback::StreamToRecord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ C4Group_DeleteItem()

bool C4Group_DeleteItem ( const char *  item_name,
bool  do_recycle 
)

Definition at line 255 of file C4Group.cpp.

256 {
257  // Parameter check
258  if (!item_name || !item_name[0])
259  {
260  return false;
261  }
262 
263  // simple item?
264  if (ItemExists(item_name))
265  {
266  if (do_recycle)
267  {
268  return EraseItemSafe(item_name);
269  }
270  else
271  {
272  return EraseItem(item_name);
273  }
274  }
275 
276  // delete from mother
277  C4Group parent;
278  char parent_path[_MAX_PATH_LEN];
279  GetParentPath(item_name, parent_path);
280 
281  // Delete original file
282  if ( !parent.Open(parent_path)
283  || !parent.DeleteEntry(GetFilename(item_name), do_recycle)
284  || !parent.Close() )
285  {
286  return false;
287  }
288 
289  return true;
290 }
bool EraseItemSafe(const char *szFilename)
Definition: C4GroupMain.cpp:42
bool DeleteEntry(const char *filename, bool do_recycle=false)
Definition: C4Group.cpp:1695

References _MAX_PATH_LEN, C4Group::Close(), C4Group::DeleteEntry(), EraseItem(), EraseItemSafe(), GetFilename(), GetParentPath(), ItemExists(), and C4Group::Open().

Referenced by C4StartupScenSelDlg::DeleteConfirm(), and C4StartupPlrSelDlg::OnDelBtnConfirm().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ C4Group_ExplodeDirectory()

bool C4Group_ExplodeDirectory ( const char *  filename)

Definition at line 470 of file C4Group.cpp.

471 {
472  // Ignore
473  if (C4Group_TestIgnore(filename))
474  {
475  return true;
476  }
477 
478  // Unpack this directory
479  if (!C4Group_UnpackDirectory(filename))
480  {
481  return false;
482  }
483 
484  // Explode all children
486 
487  // Success
488  return true;
489 }
bool C4Group_ExplodeDirectory(const char *filename)
Definition: C4Group.cpp:470
bool C4Group_TestIgnore(const char *filename)
Definition: C4Group.cpp:92
bool C4Group_UnpackDirectory(const char *filename)
Definition: C4Group.cpp:401
int ForEachFile(const char *szDirName, bool(*fnCallback)(const char *))
Definition: StdFile.cpp:1068

References C4Group_TestIgnore(), C4Group_UnpackDirectory(), and ForEachFile().

Referenced by C4Group_ApplyUpdate(), and ProcessGroup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ C4Group_GetTempPath()

const char* C4Group_GetTempPath ( )

Definition at line 87 of file C4Group.cpp.

88 {
89  return C4Group_TempPath;
90 }

References C4Group_TempPath.

Referenced by C4Surface::SavePNG().

Here is the caller graph for this function:

◆ C4Group_IsExcluded()

bool C4Group_IsExcluded ( const char *  filename,
const char *  exclude_list 
)

Definition at line 1787 of file C4Group.cpp.

1788 {
1789  // No file or no exclude list
1790  if (!filename || !filename[0] || !exclude_list || !exclude_list[0])
1791  {
1792  return false;
1793  }
1794  // Process segmented exclude list
1795  char separator = (SCharCount(';', exclude_list) ? ';' : '|');
1796  char segment[_MAX_PATH_LEN];
1797  for (int i = 0; SCopySegment(exclude_list, i, segment, separator); i++)
1798  {
1799  if (WildcardMatch(segment, GetFilename(filename)))
1800  {
1801  return true;
1802  }
1803  }
1804  // No match
1805  return false;
1806 }
unsigned int SCharCount(char cTarget, const char *szInStr, const char *cpUntil)
Definition: Standard.cpp:326
bool SCopySegment(const char *szString, int iSegment, char *sTarget, char cSeparator, int iMaxL, bool fSkipWhitespace)
Definition: Standard.cpp:279
bool WildcardMatch(const char *szWildcard, const char *szString)
Definition: StdFile.cpp:396

References _MAX_PATH_LEN, GetFilename(), SCharCount(), SCopySegment(), and WildcardMatch().

Referenced by C4Group::Extract().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ C4Group_IsGroup()

bool C4Group_IsGroup ( const char *  filename)

Definition at line 104 of file C4Group.cpp.

105 {
106  C4Group group;
107  if (group.Open(filename))
108  {
109  group.Close();
110  return true;
111  }
112  return false;
113 }

References C4Group::Close(), and C4Group::Open().

Referenced by C4MainMenu::ActivateSavegame(), C4Group_ApplyUpdate(), and C4ScenarioListLoader::Entry::RenameTo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ C4Group_MoveItem()

bool C4Group_MoveItem ( const char *  source,
const char *  target,
bool  no_sorting 
)

Definition at line 182 of file C4Group.cpp.

183 {
184  // Parameter check
185  if (!source || !target || !source[0] || !target[0])
186  {
187  return false;
188  }
189  char target_path[_MAX_PATH_LEN];
190  SCopy(target, target_path, _MAX_PATH);
191 
192  // Backslash terminator indicates target is a path only (append filename)
193  if (target_path[SLen(target_path)-1] == DirectorySeparator)
194  {
195  SAppend(GetFilename(source), target_path);
196  }
197 
198  // Check for identical source and target
199  if (ItemIdentical(source, target_path))
200  {
201  return true;
202  }
203 
204  // Source and target are simple items
205  if (ItemExists(source) && CreateItem(target_path))
206  {
207  // erase test file, because it may block moving a directory
208  EraseItem(target_path);
209  return MoveItem(source, target_path);
210  }
211 
212  // Source & target
213  C4Group source_parent;
214  C4Group target_parent;
215  char source_parent_path[_MAX_PATH_LEN];
216  char target_parent_path[_MAX_PATH_LEN];
217  GetParentPath(source, source_parent_path);
218  GetParentPath(target_path, target_parent_path);
219 
220  // Temp filename
221  char temp_filename[_MAX_PATH_LEN];
222  SCopy(C4Group_TempPath, temp_filename, _MAX_PATH);
223  SAppend(GetFilename(source),temp_filename);
224  MakeTempFilename(temp_filename);
225 
226  // Extract source to temp file
227  if ( !source_parent.Open(source_parent_path)
228  || !source_parent.Extract(GetFilename(source),temp_filename)
229  || !source_parent.Close())
230  {
231  return false;
232  }
233 
234  // Move temp file to target_path
235  if ( !target_parent.Open(target_parent_path)
236  || !target_parent.SetNoSort(no_sorting)
237  || !target_parent.Move(temp_filename, GetFilename(target_path))
238  || !target_parent.Close())
239  {
240  EraseItem(temp_filename);
241  return false;
242  }
243 
244  // Delete original file
245  if ( !source_parent.Open(source_parent_path)
246  || !source_parent.DeleteEntry(GetFilename(source))
247  || !source_parent.Close() )
248  {
249  return false;
250  }
251 
252  return true;
253 }
bool MoveItem(const char *szSource, const char *szTarget)
Definition: StdFile.cpp:873

References _MAX_PATH, _MAX_PATH_LEN, C4Group_TempPath, C4Group::Close(), CreateItem(), C4Group::DeleteEntry(), DirectorySeparator, EraseItem(), C4Group::Extract(), GetFilename(), GetParentPath(), ItemExists(), ItemIdentical(), MakeTempFilename(), C4Group::Move(), MoveItem(), C4Group::Open(), SAppend(), SCopy(), C4Group::SetNoSort(), and SLen().

Referenced by C4ScenarioListLoader::Entry::RenameTo(), and C4Player::Save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ C4Group_PackDirectory()

bool C4Group_PackDirectory ( const char *  filename)

Definition at line 371 of file C4Group.cpp.

372 {
373  // Make temporary filename
374  char temp_filename[_MAX_PATH_LEN];
375  SCopy(filename, temp_filename, _MAX_PATH);
376  MakeTempFilename(temp_filename);
377 
378  // Pack directory
379  if (!C4Group_PackDirectoryTo(filename, temp_filename))
380  {
381  return false;
382  }
383 
384  // Rename folder
385  char temp_filename2[_MAX_PATH_LEN];
386  SCopy(filename, temp_filename2, _MAX_PATH);
387  MakeTempFilename(temp_filename2);
388  if (!RenameFile(filename, temp_filename2))
389  {
390  return false;
391  }
392  // Name group file
393  if (!RenameFile(temp_filename, filename))
394  {
395  return false;
396  }
397  // Last: Delete folder
398  return EraseDirectory(temp_filename2);
399 }
bool C4Group_PackDirectoryTo(const char *filename, const char *to_filename)
Definition: C4Group.cpp:292
bool EraseDirectory(const char *szDirName)
Definition: StdFile.cpp:785
bool RenameFile(const char *szFileName, const char *szNewFileName)

References _MAX_PATH, _MAX_PATH_LEN, C4Group_PackDirectoryTo(), EraseDirectory(), MakeTempFilename(), RenameFile(), and SCopy().

Referenced by C4Network2Res::GetStandalone(), ProcessGroup(), and C4Record::Stop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ C4Group_PackDirectoryTo()

bool C4Group_PackDirectoryTo ( const char *  filename,
const char *  to_filename 
)

Definition at line 292 of file C4Group.cpp.

293 {
294  // Check file type
295  if (!DirectoryExists(filename))
296  {
297  return false;
298  }
299  // Target must not exist
300  if (FileExists(to_filename))
301  {
302  return false;
303  }
304  // Ignore
305  if (C4Group_TestIgnore(filename))
306  {
307  return true;
308  }
309  // Process message
311  {
312  C4Group_ProcessCallback(filename, 0);
313  }
314  // Create group file
315  C4Group group;
316  if (!group.Open(to_filename, true))
317  {
318  return false;
319  }
320  // Add folder contents to group
321  DirectoryIterator i(filename);
322  for (; *i; i++)
323  {
324  // Ignore
325  if (C4Group_TestIgnore(*i))
326  {
327  continue;
328  }
329  // Must pack?
330  if (DirectoryExists(*i))
331  {
332  // Find temporary filename
333  char temp_filename[_MAX_PATH_LEN];
334  // At C4Group temp path
335  SCopy(C4Group_TempPath, temp_filename, _MAX_PATH);
336  SAppend(GetFilename(*i), temp_filename, _MAX_PATH);
337  // Make temporary filename
338  MakeTempFilename(temp_filename);
339  // Pack and move into group
340  if (!C4Group_PackDirectoryTo(*i, temp_filename))
341  {
342  break;
343  }
344  if (!group.Move(temp_filename, GetFilename(*i)))
345  {
346  EraseFile(temp_filename);
347  break;
348  }
349  }
350  // Add normally otherwise
351  else if (!group.Add(*i, nullptr))
352  {
353  break;
354  }
355  }
356  // Something went wrong?
357  if (*i)
358  {
359  // Close group and remove temporary file
360  group.Close();
361  EraseItem(to_filename);
362  return false;
363  }
364  // Reset iterator
365  i.Reset();
366  // Close group
367  group.SortByList(C4Group_SortList, filename);
368  return group.Close();
369 }
const char ** C4Group_SortList
Definition: C4Group.cpp:61
bool(* C4Group_ProcessCallback)(const char *, int)
Definition: C4Group.cpp:62
bool DirectoryExists(const char *szFilename)
Definition: StdFile.cpp:708
bool FileExists(const char *szFileName)
bool EraseFile(const char *szFileName)
bool Add(const char *filename, const char *entry_name)
Definition: C4Group.cpp:1621
bool SortByList(const char **list, const char *filename=nullptr)
Definition: C4Group.cpp:2566

References _MAX_PATH, _MAX_PATH_LEN, C4Group::Add(), C4Group_ProcessCallback, C4Group_SortList, C4Group_TempPath, C4Group_TestIgnore(), C4Group::Close(), DirectoryExists(), EraseFile(), EraseItem(), FileExists(), GetFilename(), MakeTempFilename(), C4Group::Move(), C4Group::Open(), DirectoryIterator::Reset(), SAppend(), SCopy(), and C4Group::SortByList().

Referenced by C4ControlJoinPlayer::C4ControlJoinPlayer(), C4Group_PackDirectory(), C4Network2Res::GetStandalone(), ProcessGroup(), and C4Console::SaveScenario().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ C4Group_ReadFile()

bool C4Group_ReadFile ( const char *  filename,
char **  data,
size_t *  size 
)

Definition at line 491 of file C4Group.cpp.

492 {
493  // security
494  if (!filename || !data)
495  {
496  return false;
497  }
498 
499  // get mother path & file name
500  char parent_path[_MAX_PATH_LEN];
501  GetParentPath(filename, parent_path);
502  const char *entry_name = GetFilename(filename);
503 
504  // open parent group
505  C4Group parent_group;
506  if (!parent_group.Open(parent_path))
507  {
508  return false;
509  }
510  // access the file
511  size_t filesize;
512  if (!parent_group.AccessEntry(entry_name, &filesize))
513  {
514  return false;
515  }
516  // create buffer
517  *data = new char [filesize];
518  // read it
519  if (!parent_group.Read(*data, filesize))
520  {
521  delete [] *data;
522  *data = nullptr;
523  return false;
524  }
525  // ok
526  parent_group.Close();
527  if (size)
528  {
529  *size = filesize;
530  }
531  return true;
532 }
bool Read(void *buffer, size_t size) override
Definition: C4Group.cpp:1430
bool AccessEntry(const char *wildcard, size_t *size=nullptr, char *filename=nullptr, bool needs_to_be_a_group=false)
Definition: C4Group.cpp:2104

References _MAX_PATH_LEN, C4Group::AccessEntry(), C4Group::Close(), GetFilename(), GetParentPath(), C4Group::Open(), and C4Group::Read().

Referenced by C4MusicFileSDL::Play().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ C4Group_SetProcessCallback()

void C4Group_SetProcessCallback ( bool(*)(const char *, int)  callback)

Definition at line 64 of file C4Group.cpp.

65 {
66  C4Group_ProcessCallback = callback;
67 }

References C4Group_ProcessCallback.

Referenced by C4Application::DoInit().

Here is the caller graph for this function:

◆ C4Group_SetSortList()

void C4Group_SetSortList ( const char **  sort_list)

Definition at line 69 of file C4Group.cpp.

70 {
71  C4Group_SortList = sort_list;
72 }

References C4Group_SortList.

Referenced by C4Application::DoInit(), main(), and ProcessGroup().

Here is the caller graph for this function:

◆ C4Group_SetTempPath()

void C4Group_SetTempPath ( const char *  path)

Definition at line 74 of file C4Group.cpp.

75 {
76  if (!path || !path[0])
77  {
78  C4Group_TempPath[0] = 0;
79  }
80  else
81  {
84  }
85 }
void AppendBackslash(char *szFilename)
Definition: StdFile.cpp:254

References _MAX_PATH, AppendBackslash(), C4Group_TempPath, and SCopy().

Referenced by C4Application::DoInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ C4Group_TestIgnore()

bool C4Group_TestIgnore ( const char *  filename)

Definition at line 92 of file C4Group.cpp.

93 {
94  if (!*filename)
95  {
96  return true; //poke out empty strings
97  }
98  const char* name = GetFilename(filename);
99  return *name == '.' //no hidden files and the directory itself
100  || name[strlen(name) - 1] == '~' //no temp files
101  || SIsModule(C4Group_Ignore, name); //not on Blacklist
102 }
char C4Group_Ignore[_MAX_PATH_LEN]
Definition: C4Group.cpp:60
bool SIsModule(const char *szList, const char *szString, int *ipIndex, bool fCaseSensitive)
Definition: Standard.cpp:547

References C4Group_Ignore, GetFilename(), and SIsModule().

Referenced by C4Group_ExplodeDirectory(), C4Group_PackDirectoryTo(), DirContainsScenarios(), and C4ScenarioListLoader::RegularFolder::DoLoadContents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ C4Group_UnpackDirectory()

bool C4Group_UnpackDirectory ( const char *  filename)

Definition at line 401 of file C4Group.cpp.

402 {
403  // Already unpacked: success
404  if (DirectoryExists(filename))
405  {
406  return true;
407  }
408 
409  // Not a real file: unpack mother directory first
410  char parent_filename[_MAX_PATH_LEN];
411  if (!FileExists(filename)
412  && GetParentPath(filename, parent_filename)
413  && !C4Group_UnpackDirectory(parent_filename))
414  {
415  return false;
416  }
417 
418  // Open group
419  C4Group group;
420  if (!group.Open(filename))
421  {
422  return false;
423  }
424 
425  // Process message
427  {
428  C4Group_ProcessCallback(filename, 0);
429  }
430 
431  // Create target directory
432  char target_directory[_MAX_PATH_LEN];
433  SCopy(filename, target_directory, _MAX_PATH);
434  MakeTempFilename(target_directory);
435  if (!CreatePath(target_directory))
436  {
437  group.Close();
438  return false;
439  }
440 
441  // Extract files to folder
442  if (!group.Extract("*",target_directory))
443  {
444  group.Close();
445  return false;
446  }
447 
448  // Close group
449  group.Close();
450 
451  // Rename group file
452  char temp_filename[_MAX_PATH_LEN];
453  SCopy(filename, temp_filename, _MAX_PATH);
454  MakeTempFilename(temp_filename);
455  if (!RenameFile(filename, temp_filename))
456  {
457  return false;
458  }
459 
460  // Rename target directory
461  if (!RenameFile(target_directory, filename))
462  {
463  return false;
464  }
465 
466  // Delete renamed group file
467  return EraseItem(temp_filename);
468 }
bool CreatePath(const std::string &path)
Definition: StdFile.cpp:656

References _MAX_PATH, _MAX_PATH_LEN, C4Group_ProcessCallback, C4Group::Close(), CreatePath(), DirectoryExists(), EraseItem(), C4Group::Extract(), FileExists(), GetParentPath(), MakeTempFilename(), C4Group::Open(), RenameFile(), and SCopy().

Referenced by C4Group_ExplodeDirectory(), C4UpdatePackage::Execute(), C4Language::Init(), ProcessGroup(), C4Network2::RetrieveScenario(), C4Record::Start(), and C4Playback::StreamToRecord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MemScramble()

void MemScramble ( BYTE buffer,
int  size 
)

Definition at line 534 of file C4Group.cpp.

535 {
536  // XOR deface
537  for (int cnt = 0; cnt < size; cnt++)
538  {
539  buffer[cnt] ^= 237;
540  }
541  // BYTE swap
542  for (int cnt = 0; cnt + 2 < size; cnt += 3)
543  {
544  BYTE temp = buffer[cnt];
545  buffer[cnt] = buffer[cnt + 2];
546  buffer[cnt + 2] = temp;
547  }
548 }
uint8_t BYTE

Referenced by C4UpdatePackage::MakeUpdate(), C4Group::OpenAsChild(), and C4Group::Save().

Here is the caller graph for this function:

◆ SortRank()

int SortRank ( const char *  element,
const char *  sort_list 
)

Definition at line 2455 of file C4Group.cpp.

2456 {
2457  char segment[_MAX_FNAME_LEN];
2458 
2459  for (int cnt = 0; SCopySegment(sort_list, cnt, segment,'|',_MAX_FNAME); cnt++)
2460  {
2461  if (WildcardMatch(segment, element))
2462  {
2463  return (SCharCount('|',sort_list) + 1) - cnt;
2464  }
2465  }
2466 
2467  return 0;
2468 }
#define _MAX_FNAME
#define _MAX_FNAME_LEN

References _MAX_FNAME, _MAX_FNAME_LEN, SCharCount(), SCopySegment(), and WildcardMatch().

Referenced by C4Group::Sort().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ C4CFN_FLS

const char* C4CFN_FLS[]
Initial value:
=
{
nullptr, nullptr
}
#define C4FLS_Player
Definition: C4Components.h:194
#define C4CFN_Graphics
Definition: C4Components.h:28
#define C4FLS_Section
Definition: C4Components.h:190
#define C4FLS_Scenario
Definition: C4Components.h:189
#define C4FLS_Sound
Definition: C4Components.h:204
#define C4CFN_Music
Definition: C4Components.h:30
#define C4CFN_PlayerFiles
Definition: C4Components.h:168
#define C4FLS_Music
Definition: C4Components.h:205
#define C4CFN_System
Definition: C4Components.h:29
#define C4CFN_Material
Definition: C4Components.h:25
#define C4CFN_ScenarioSections
Definition: C4Components.h:38
#define C4CFN_Sound
Definition: C4Components.h:26
#define C4FLS_Material
Definition: C4Components.h:197
#define C4FLS_Def
Definition: C4Components.h:193
#define C4FLS_Folder
Definition: C4Components.h:196
#define C4CFN_ScenarioFiles
Definition: C4Components.h:175
#define C4FLS_Object
Definition: C4Components.h:195
#define C4FLS_System
Definition: C4Components.h:203
#define C4CFN_DefFiles
Definition: C4Components.h:166
#define C4FLS_Graphics
Definition: C4Components.h:198
#define C4CFN_ObjectInfoFiles
Definition: C4Components.h:170
#define C4CFN_FolderFiles
Definition: C4Components.h:176

Definition at line 32 of file C4Group.cpp.

Referenced by C4Application::DoInit(), and main().

◆ C4Group_Ignore

char C4Group_Ignore[_MAX_PATH_LEN] ="cvs;CVS;Thumbs.db;.orig;.svn"

Definition at line 60 of file C4Group.cpp.

Referenced by C4Group_TestIgnore().

◆ C4Group_ProcessCallback

bool(* C4Group_ProcessCallback) (const char *, int) ( const char *  ,
int   
) = nullptr

◆ C4Group_SortList

const char** C4Group_SortList = nullptr

◆ C4Group_TempPath