MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / expandShortPath

Function expandShortPath

app/src/API/PathPolicy.cpp:39–60  ·  view source on GitHub ↗

* @brief Expand a Windows 8.3 short path (e.g. RUNNER~1) to its long form. */

Source from the content-addressed store, hash-verified

37 * @brief Expand a Windows 8.3 short path (e.g. RUNNER~1) to its long form.
38 */
39static 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.

Callers 1

normalizedPathFunction · 0.85

Calls 3

isEmptyMethod · 0.80
dataMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected