GH-1997 fix off by one error in 8.3 path logic
This commit is contained in:
parent
d276da1359
commit
79d208795c
@ -36,8 +36,13 @@ QString shortPathName(const QString & file)
|
|||||||
auto input = file.toStdWString();
|
auto input = file.toStdWString();
|
||||||
std::wstring output;
|
std::wstring output;
|
||||||
long length = GetShortPathNameW(input.c_str(), NULL, 0);
|
long length = GetShortPathNameW(input.c_str(), NULL, 0);
|
||||||
|
// NOTE: this resizing might seem weird...
|
||||||
|
// when GetShortPathNameW fails, it returns length including null character
|
||||||
|
// when it succeeds, it returns length excluding null character
|
||||||
|
// See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364989(v=vs.85).aspx
|
||||||
output.resize(length);
|
output.resize(length);
|
||||||
GetShortPathNameW(input.c_str(),(LPWSTR)output.c_str(),length);
|
GetShortPathNameW(input.c_str(),(LPWSTR)output.c_str(),length);
|
||||||
|
output.resize(length-1);
|
||||||
QString ret = QString::fromStdWString(output);
|
QString ret = QString::fromStdWString(output);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user