MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / GenArcName

Function GenArcName

Libraries/unrar/pathfn.cpp:683–846  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

681
682#ifndef SFX_MODULE
683static void GenArcName(wchar *ArcName,size_t MaxSize,const wchar *GenerateMask,uint ArcNumber,bool &ArcNumPresent)
684{
685 bool Prefix=false;
686 if (*GenerateMask=='+')
687 {
688 Prefix=true; // Add the time string before the archive name.
689 GenerateMask++; // Skip '+' in the beginning of time mask.
690 }
691
692 wchar Mask[MAX_GENERATE_MASK];
693 wcsncpyz(Mask,*GenerateMask!=0 ? GenerateMask:L"yyyymmddhhmmss",ASIZE(Mask));
694
695 bool QuoteMode=false,Hours=false;
696 for (uint I=0;Mask[I]!=0;I++)
697 {
698 if (Mask[I]=='{' || Mask[I]=='}')
699 {
700 QuoteMode=(Mask[I]=='{');
701 continue;
702 }
703 if (QuoteMode)
704 continue;
705 int CurChar=toupperw(Mask[I]);
706 if (CurChar=='H')
707 Hours=true;
708
709 if (Hours && CurChar=='M')
710 {
711 // Replace minutes with 'I'. We use 'M' both for months and minutes,
712 // so we treat as minutes only those 'M' which are found after hours.
713 Mask[I]='I';
714 }
715 if (CurChar=='N')
716 {
717 uint Digits=GetDigits(ArcNumber);
718 uint NCount=0;
719 while (toupperw(Mask[I+NCount])=='N')
720 NCount++;
721
722 // Here we ensure that we have enough 'N' characters to fit all digits
723 // of archive number. We'll replace them by actual number later
724 // in this function.
725 if (NCount<Digits)
726 {
727 wmemmove(Mask+I+Digits,Mask+I+NCount,wcslen(Mask+I+NCount)+1);
728 wmemset(Mask+I,'N',Digits);
729 }
730 I+=Max(Digits,NCount)-1;
731 ArcNumPresent=true;
732 continue;
733 }
734 }
735
736 RarTime CurTime;
737 CurTime.SetCurrentTime();
738 RarLocalTime rlt;
739 CurTime.GetLocal(&rlt);
740

Callers 1

GenerateArchiveNameFunction · 0.85

Calls 12

wcsncpyzFunction · 0.85
toupperwFunction · 0.85
GetDigitsFunction · 0.85
GetExtFunction · 0.85
PointToNameFunction · 0.85
IsLeapYearFunction · 0.85
GetMonthNameFunction · 0.85
GetFilePathFunction · 0.85
AddEndSlashFunction · 0.85
wcsncatzFunction · 0.85
SetCurrentTimeMethod · 0.80
GetLocalMethod · 0.80

Tested by

no test coverage detected