Get the name of first volume. Return the leftmost digit of volume number.
| 1061 | #if !defined(SFX_MODULE) && !defined(SETUP) |
| 1062 | // Get the name of first volume. Return the leftmost digit of volume number. |
| 1063 | char* 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 |