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

Function GenerateArchiveName

Libraries/unrar/pathfn.cpp:849–879  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

847
848
849void GenerateArchiveName(wchar *ArcName,size_t MaxSize,const wchar *GenerateMask,bool Archiving)
850{
851 wchar NewName[NM];
852
853 uint ArcNumber=1;
854 while (true) // Loop for 'N' (archive number) processing.
855 {
856 wcsncpyz(NewName,ArcName,ASIZE(NewName));
857
858 bool ArcNumPresent=false;
859
860 GenArcName(NewName,ASIZE(NewName),GenerateMask,ArcNumber,ArcNumPresent);
861
862 if (!ArcNumPresent)
863 break;
864 if (!FileExist(NewName))
865 {
866 if (!Archiving && ArcNumber>1)
867 {
868 // If we perform non-archiving operation, we need to use the last
869 // existing archive before the first unused name. So we generate
870 // the name for (ArcNumber-1) below.
871 wcsncpyz(NewName,NullToEmpty(ArcName),ASIZE(NewName));
872 GenArcName(NewName,ASIZE(NewName),GenerateMask,ArcNumber-1,ArcNumPresent);
873 }
874 break;
875 }
876 ArcNumber++;
877 }
878 wcsncpyz(ArcName,NewName,MaxSize);
879}
880#endif
881
882

Callers 1

ProcessCommandMethod · 0.85

Calls 4

wcsncpyzFunction · 0.85
GenArcNameFunction · 0.85
FileExistFunction · 0.85
NullToEmptyFunction · 0.85

Tested by

no test coverage detected