| 626 | // http://www.geocities.com/SiliconValley/2060/articles/longpaths.html |
| 627 | |
| 628 | static bool ShortToLongPathName(tstring& Path) |
| 629 | { |
| 630 | // Special characters. |
| 631 | const char sep = '\\'; |
| 632 | const char colon = ':'; |
| 633 | |
| 634 | // Copy the short path into the work buffer and convert forward |
| 635 | // slashes to backslashes. |
| 636 | translate_slashes(Path); |
| 637 | |
| 638 | // We need a couple of markers for stepping through the path. |
| 639 | size left = 0; |
| 640 | size right = 0; |
| 641 | bool found_root = false; |
| 642 | |
| 643 | // Parse the first bit of the path. |
| 644 | // Probably has to change to use GetDriveType. |
| 645 | if (Path.length() >= 2 && isDriveLetter(Path[0]) && colon == Path[1]) // Drive letter? |
| 646 | { |
| 647 | if (Path.length() == 2) // 'bare' drive letter |
| 648 | { |
| 649 | right = npos; // skip main block |
| 650 | } |
| 651 | else if (sep == Path[2]) // drive letter + backslash |
| 652 | { |
| 653 | // FindFirstFile doesn't like "X:\" |
| 654 | if (Path.length() == 3) |
| 655 | { |
| 656 | right = npos; // skip main block |
| 657 | } |
| 658 | else |
| 659 | { |
| 660 | left = right = 3; |
| 661 | found_root = true; |
| 662 | } |
| 663 | } |
| 664 | else |
| 665 | { |
| 666 | return false; // parsing failure |
| 667 | } |
| 668 | } |
| 669 | else if (Path.length() >= 1 && sep == Path[0]) |
| 670 | { |
| 671 | if (Path.length() == 1) // 'bare' backslash |
| 672 | { |
| 673 | right = npos; // skip main block |
| 674 | } |
| 675 | else |
| 676 | { |
| 677 | if (sep == Path[1]) // is it UNC? |
| 678 | { |
| 679 | // Find end of machine name |
| 680 | right = Path.find_first_of(sep, 2); |
| 681 | if (npos == right) |
| 682 | { |
| 683 | return false; |
| 684 | } |
| 685 |
no test coverage detected