Get the name of first volume. Return the leftmost digit of volume number.
| 625 | #if !defined(SFX_MODULE) |
| 626 | // Get the name of first volume. Return the leftmost digit of volume number. |
| 627 | wchar* VolNameToFirstName(const wchar *VolName,wchar *FirstName,size_t MaxSize,bool NewNumbering) |
| 628 | { |
| 629 | if (FirstName!=VolName) |
| 630 | wcsncpyz(FirstName,VolName,MaxSize); |
| 631 | wchar *VolNumStart=FirstName; |
| 632 | if (NewNumbering) |
| 633 | { |
| 634 | wchar N='1'; |
| 635 | |
| 636 | // From the rightmost digit of volume number to the left. |
| 637 | for (wchar *ChPtr=GetVolNumPart(FirstName);ChPtr>FirstName;ChPtr--) |
| 638 | if (IsDigit(*ChPtr)) |
| 639 | { |
| 640 | *ChPtr=N; // Set the rightmost digit to '1' and others to '0'. |
| 641 | N='0'; |
| 642 | } |
| 643 | else |
| 644 | if (N=='0') |
| 645 | { |
| 646 | VolNumStart=ChPtr+1; // Store the position of leftmost digit in volume number. |
| 647 | break; |
| 648 | } |
| 649 | } |
| 650 | else |
| 651 | { |
| 652 | // Old volume numbering scheme. Just set the extension to ".rar". |
| 653 | SetExt(FirstName,L"rar",MaxSize); |
| 654 | VolNumStart=GetExt(FirstName); |
| 655 | } |
| 656 | if (!FileExist(FirstName)) |
| 657 | { |
| 658 | // If the first volume, which name we just generated, is not exist, |
| 659 | // check if volume with same name and any other extension is available. |
| 660 | // It can help in case of *.exe or *.sfx first volume. |
| 661 | wchar Mask[NM]; |
| 662 | wcsncpyz(Mask,FirstName,ASIZE(Mask)); |
| 663 | SetExt(Mask,L"*",ASIZE(Mask)); |
| 664 | FindFile Find; |
| 665 | Find.SetMask(Mask); |
| 666 | FindData FD; |
| 667 | while (Find.Next(&FD)) |
| 668 | { |
| 669 | Archive Arc; |
| 670 | if (Arc.Open(FD.Name,0) && Arc.IsArchive(true) && Arc.FirstVolume) |
| 671 | { |
| 672 | wcsncpyz(FirstName,FD.Name,MaxSize); |
| 673 | break; |
| 674 | } |
| 675 | } |
| 676 | } |
| 677 | return VolNumStart; |
| 678 | } |
| 679 | #endif |
| 680 | |
| 681 |
no test coverage detected