MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / ShortToLongPathName

Function ShortToLongPathName

src/common/isc_file.cpp:628–831  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

626// http://www.geocities.com/SiliconValley/2060/articles/longpaths.html
627
628static 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

Callers 1

ISC_expand_filenameFunction · 0.85

Calls 8

translate_slashesFunction · 0.85
isDriveLetterFunction · 0.85
lengthMethod · 0.45
find_first_ofMethod · 0.45
find_last_ofMethod · 0.45
c_strMethod · 0.45
atMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected