Don't assume a max length in fs::ShortName
This commit is contained in:
parent
d96fc1f70d
commit
1734f00d8a
1 changed files with 5 additions and 1 deletions
|
@ -35,7 +35,11 @@ namespace bfs = boost::filesystem;
|
||||||
|
|
||||||
namespace agi { namespace fs {
|
namespace agi { namespace fs {
|
||||||
std::string ShortName(path const& p) {
|
std::string ShortName(path const& p) {
|
||||||
std::wstring out(MAX_PATH + 1, 0);
|
DWORD length = GetShortPathName(p.c_str(), NULL, 0);
|
||||||
|
if (!length)
|
||||||
|
return p.string();
|
||||||
|
|
||||||
|
std::wstring out(length, 0);
|
||||||
DWORD len = GetShortPathName(p.c_str(), &out[0], out.size());
|
DWORD len = GetShortPathName(p.c_str(), &out[0], out.size());
|
||||||
if (!len)
|
if (!len)
|
||||||
return p.string();
|
return p.string();
|
||||||
|
|
Loading…
Reference in a new issue