MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / Create

Method Create

engine/Poseidon/IO/PackFiles.cpp:485–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

483}
484
485LSError FileBankManager::Create(const char* tgt, const char* src, bool compress, bool optimize, const char* logFile,
486 const char** doNotCompress, const QFProperty* properties, int nProperties)
487{
488 newestFile = 0;
489 size = 0;
490
491 files.Resize(0);
492 files.Realloc(1024);
493 RString folder = src;
494 RString target = tgt;
495 ScanDir(folder, "");
496
497 if (logFile)
498 {
499 ParseMasks(logFile);
500 }
501 SortAndRemove(logFile != nullptr);
502 // repack only if destination is older than all sources
503
504 if (!optimize)
505 {
506 Fail("Obsolete: Optimized format should be used");
507 }
508
509 int destTime = FileTime(target);
510 if (destTime >= newestFile)
511 {
512 LOG_DEBUG(Core, "{} skipped - no changes detected.\n", (const char*)folder);
513 return LSOK;
514 }
515
516 const char* action = "Repacking";
517 if (compress)
518 {
519 action = "Compressing";
520 }
521 else if (optimize)
522 {
523 action = "Optimizing";
524 }
525 LOG_DEBUG(Core, "{}: {} {} files ({} KB).\n", (const char*)folder, action, files.Size(), (size + 1023) / 1024);
526
527 if (!compress)
528 {
529 // save headers
530 SOFStream out;
531 out.open(target);
532 out.setbuffer(1024 * 1024);
533 SaveProperties(out, properties, nProperties);
534 SaveHeadersOpt(out);
535 for (int i = 0; i < files.Size(); i++)
536 {
537 FileInfoExt& file = files[i];
538 RString inFilename = folder + RString(DIR_STR) + HostPathFromBankEntryName(file.name);
539 QIFStream in;
540 in.open(inFilename);
541 out.write(in.act(), in.rest());
542 }

Callers 6

PackMethod · 0.45
InitMissionMethod · 0.45
OnChildDestroyedMethod · 0.45
DoLoadHeadersMethod · 0.45
CreateTempAddonBankFunction · 0.45

Calls 15

FileTimeFunction · 0.85
GetFileExtFunction · 0.85
actMethod · 0.80
restMethod · 0.80
tellpMethod · 0.80
seekpMethod · 0.80
strMethod · 0.80
pcountMethod · 0.80
StringInListFunction · 0.70
statClass · 0.70
RStringClass · 0.50

Tested by 1

CreateTempAddonBankFunction · 0.36