MCPcopy Create free account
hub / github.com/PrismLauncher/PrismLauncher / shortPathName

Function shortPathName

launcher/FileSystem.cpp:1650–1667  ·  view source on GitHub ↗

returns 8.3 file format from long path

Source from the content-addressed store, hash-verified

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

Callers 1

getPathNameInLocal8bitFunction · 0.85

Calls 1

resizeMethod · 0.80

Tested by

no test coverage detected