in host/common/win32/portablehelpersmajor.cpp [2921:2964]
void FormatVolumeName(std::string& sName, bool bUnicodeFormat)
{
if (IsVolumeNameInGuidFormat(sName))
return;
if (IsDrive(sName))
{
if ((true == bUnicodeFormat) && (false == sName.empty()) && (sName.find("\\\\.\\", 0) == std::string::npos))
{
if (sName.length() == 1 || (2 == sName.length() && ':' == sName[1]) || (3 == sName.length() && ':' == sName[1] && '\\' == sName[2]))
{
//
// If volume name is a drive letter, map it to \\.\\X:
// otherwise, just leave it as the device directory (e.g. x:\mnt\my_dir)
//
sName = "\\\\.\\" + sName;
if (sName.rfind(":") == std::string::npos)
{
sName = sName + ":";
}
std::string::size_type len = sName.length();
std::string::size_type idx = len;
if ('\\' == sName[len - 1] && ':' == sName[len - 2]) {
--idx;
}
if (idx < len) {
sName.erase(idx);
}
}
}
else
{
if (sName.rfind(":") == std::string::npos)
sName += ":";
if (sName.rfind("\\") == std::string::npos)
sName += "\\";
}
}
else if (IsMountPoint(sName))
FormatVolumeNameForMountPoint(sName);
}