* @brief Expand a Windows 8.3 short path (e.g. RUNNER~1) to its long form. */
| 37 | * @brief Expand a Windows 8.3 short path (e.g. RUNNER~1) to its long form. |
| 38 | */ |
| 39 | static QString expandShortPath(const QString& path) |
| 40 | { |
| 41 | #ifdef Q_OS_WIN |
| 42 | if (path.isEmpty()) |
| 43 | return path; |
| 44 | |
| 45 | const std::wstring input = path.toStdWString(); |
| 46 | const DWORD needed = GetLongPathNameW(input.c_str(), nullptr, 0); |
| 47 | if (needed == 0) |
| 48 | return path; |
| 49 | |
| 50 | std::wstring buffer(needed, L'\0'); |
| 51 | const DWORD written = GetLongPathNameW(input.c_str(), buffer.data(), needed); |
| 52 | if (written == 0 || written >= needed) |
| 53 | return path; |
| 54 | |
| 55 | buffer.resize(written); |
| 56 | return QDir::cleanPath(QString::fromStdWString(buffer)); |
| 57 | #else |
| 58 | return path; |
| 59 | #endif |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * @brief Returns a canonical absolute path, optionally permitting non-existent files. |
no test coverage detected