Changed GetLong/ShortPath to allocate memory dynamically
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9566 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -493,22 +493,23 @@ wxString wxFileName::GetShortPath() const
|
|||||||
{
|
{
|
||||||
#if defined(__WXMSW__) && defined(__WIN32__)
|
#if defined(__WXMSW__) && defined(__WIN32__)
|
||||||
wxString path(GetFullPath());
|
wxString path(GetFullPath());
|
||||||
|
wxString pathOut;
|
||||||
wxChar outBuf[MAX_PATH];
|
DWORD sz = ::GetShortPathName(path, NULL, 0);
|
||||||
|
bool ok = sz != 0;
|
||||||
// TODO: can't work out how to determine if the function failed
|
if ( ok )
|
||||||
// (positive value if either it succeeded or the buffer was too small)
|
|
||||||
|
|
||||||
int bufSz = ::GetShortPathName((const wxChar*) path, outBuf, MAX_PATH*sizeof(wxChar));
|
|
||||||
|
|
||||||
if (bufSz == 0)
|
|
||||||
{
|
{
|
||||||
return wxEmptyString;
|
ok = ::GetShortPathName
|
||||||
|
(
|
||||||
|
path,
|
||||||
|
pathOut.GetWriteBuf(sz),
|
||||||
|
sz
|
||||||
|
) != 0;
|
||||||
|
pathOut.UngetWriteBuf();
|
||||||
}
|
}
|
||||||
|
if (ok)
|
||||||
|
return pathOut;
|
||||||
else
|
else
|
||||||
{
|
return path;
|
||||||
return wxString(outBuf);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
return GetFullPath();
|
return GetFullPath();
|
||||||
#endif
|
#endif
|
||||||
@@ -519,22 +520,23 @@ wxString wxFileName::GetLongPath() const
|
|||||||
{
|
{
|
||||||
#if defined(__WXMSW__) && defined(__WIN32__)
|
#if defined(__WXMSW__) && defined(__WIN32__)
|
||||||
wxString path(GetFullPath());
|
wxString path(GetFullPath());
|
||||||
|
wxString pathOut;
|
||||||
wxChar outBuf[MAX_PATH];
|
DWORD sz = ::GetLongPathName(path, NULL, 0);
|
||||||
|
bool ok = sz != 0;
|
||||||
// TODO: can't work out how to determine if the function failed
|
if ( ok )
|
||||||
// (positive value if either it succeeded or the buffer was too small)
|
|
||||||
|
|
||||||
int bufSz = ::GetLongPathName((const wxChar*) path, outBuf, MAX_PATH*sizeof(wxChar));
|
|
||||||
|
|
||||||
if (bufSz == 0)
|
|
||||||
{
|
{
|
||||||
return wxEmptyString;
|
ok = ::GetLongPathName
|
||||||
|
(
|
||||||
|
path,
|
||||||
|
pathOut.GetWriteBuf(sz),
|
||||||
|
sz
|
||||||
|
) != 0;
|
||||||
|
pathOut.UngetWriteBuf();
|
||||||
}
|
}
|
||||||
|
if (ok)
|
||||||
|
return pathOut;
|
||||||
else
|
else
|
||||||
{
|
return path;
|
||||||
return wxString(outBuf);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
return GetFullPath();
|
return GetFullPath();
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user