MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / shortPathName

Function shortPathName

launcher/FileSystem.cpp:1659–1676  ·  view source on GitHub ↗

returns 8.3 file format from long path

Source from the content-addressed store, hash-verified

1657#ifdef Q_OS_WIN
1658// returns 8.3 file format from long path
1659QString shortPathName(const QString& file)
1660{
1661 auto input = file.toStdWString();
1662 std::wstring output;
1663 long length = GetShortPathNameW(input.c_str(), NULL, 0);
1664 if (length == 0)
1665 return {};
1666 // NOTE: this resizing might seem weird...
1667 // when GetShortPathNameW fails, it returns length including null character
1668 // when it succeeds, it returns length excluding null character
1669 // See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364989(v=vs.85).aspx
1670 output.resize(length);
1671 if (GetShortPathNameW(input.c_str(), (LPWSTR)output.c_str(), length) == 0)
1672 return {};
1673 output.resize(length - 1);
1674 QString ret = QString::fromStdWString(output);
1675 return ret;
1676}
1677
1678// if the string survives roundtrip through local 8bit encoding...
1679bool fitsInLocal8bit(const QString& string)

Callers 1

getPathNameInLocal8bitFunction · 0.85

Calls 1

resizeMethod · 0.80

Tested by

no test coverage detected