Returns the short path of the specified file. @param p_File File path. @return Short path.
| 60 | // @return Short path. |
| 61 | // |
| 62 | std::wstring ShortPathPlugin::GetPath(const std::wstring& p_File) const |
| 63 | { |
| 64 | assert(m_pSettings != nullptr); |
| 65 | |
| 66 | std::wstring path(p_File); |
| 67 | if (!path.empty()) { |
| 68 | const auto bufferSize = ::GetShortPathNameW(p_File.c_str(), nullptr, 0); |
| 69 | if (bufferSize != 0) { |
| 70 | std::wstring shortPath(bufferSize, L'\0'); |
| 71 | if (::GetShortPathNameW(p_File.c_str(), &*shortPath.begin(), gsl::narrow<DWORD>(shortPath.size())) != 0) { |
| 72 | path = shortPath.c_str(); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | // Append separator if needed. |
| 77 | if (m_pSettings != nullptr && m_pSettings->GetAppendSeparatorForDirectories() && PluginUtils::IsDirectory(path)) { |
| 78 | path += L"\\"; |
| 79 | } |
| 80 | } |
| 81 | return path; |
| 82 | } |
| 83 | |
| 84 | // |
| 85 | // Protected constructor with custom description and help text resources. |
nothing calls this directly
no test coverage detected