returns 8.3 file format from long path
| 1648 | #ifdef Q_OS_WIN |
| 1649 | // returns 8.3 file format from long path |
| 1650 | QString 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... |
| 1670 | bool fitsInLocal8bit(const QString& string) |
no test coverage detected