MCPcopy Create free account
hub / github.com/ararog/Unrar4iOS / VolNameToFirstName

Function VolNameToFirstName

Unrar4iOS/unrar/pathfn.cpp:1063–1114  ·  view source on GitHub ↗

Get the name of first volume. Return the leftmost digit of volume number.

Source from the content-addressed store, hash-verified

1061#if !defined(SFX_MODULE) && !defined(SETUP)
1062// Get the name of first volume. Return the leftmost digit of volume number.
1063char* VolNameToFirstName(const char *VolName,char *FirstName,bool NewNumbering)
1064{
1065 if (FirstName!=VolName)
1066 strcpy(FirstName,VolName);
1067 char *VolNumStart=FirstName;
1068 if (NewNumbering)
1069 {
1070 char N='1';
1071
1072 // From the rightmost digit of volume number to the left.
1073 for (char *ChPtr=GetVolNumPart(FirstName);ChPtr>FirstName;ChPtr--)
1074 if (IsDigit(*ChPtr))
1075 {
1076 *ChPtr=N; // Set the rightmost digit to '1' and others to '0'.
1077 N='0';
1078 }
1079 else
1080 if (N=='0')
1081 {
1082 VolNumStart=ChPtr+1; // Store the position of leftmost digit in volume number.
1083 break;
1084 }
1085 }
1086 else
1087 {
1088 // Old volume numbering scheme. Just set the extension to ".rar".
1089 SetExt(FirstName,"rar");
1090 VolNumStart=GetExt(FirstName);
1091 }
1092 if (!FileExist(FirstName))
1093 {
1094 // If the first volume, which name we just generated, is not exist,
1095 // check if volume with same name and any other extension is available.
1096 // It can help in case of *.exe or *.sfx first volume.
1097 char Mask[NM];
1098 strcpy(Mask,FirstName);
1099 SetExt(Mask,"*");
1100 FindFile Find;
1101 Find.SetMask(Mask);
1102 FindData FD;
1103 while (Find.Next(&FD))
1104 {
1105 Archive Arc;
1106 if (Arc.Open(FD.Name,FD.NameW,0) && Arc.IsArchive(true) && !Arc.NotFirstVolume)
1107 {
1108 strcpy(FirstName,FD.Name);
1109 break;
1110 }
1111 }
1112 }
1113 return(VolNumStart);
1114}
1115#endif
1116
1117

Callers 3

RestoreMethod · 0.85
ExtractArchiveMethod · 0.85
extract.cppFile · 0.85

Calls 10

GetVolNumPartFunction · 0.85
IsDigitFunction · 0.85
SetExtFunction · 0.85
GetExtFunction · 0.85
FileExistFunction · 0.85
SetMaskMethod · 0.80
NextMethod · 0.80
OpenMethod · 0.80
IsArchiveMethod · 0.80
SetMaskWMethod · 0.80

Tested by

no test coverage detected