Remove dynamic loading of GetLongPathName.
GetLongPathName is available since WinXP.
This commit is contained in:
parent
c5ce5bf168
commit
55c76ed087
@ -2152,60 +2152,21 @@ wxString wxFileName::GetLongPath() const
|
|||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__WIN32__)
|
||||||
|
|
||||||
#if wxUSE_DYNLIB_CLASS
|
DWORD dwSize = ::GetLongPathName(path.t_str(), NULL, 0);
|
||||||
typedef DWORD (WINAPI *GET_LONG_PATH_NAME)(const wxChar *, wxChar *, DWORD);
|
if ( dwSize > 0 )
|
||||||
|
|
||||||
// this is MT-safe as in the worst case we're going to resolve the function
|
|
||||||
// twice -- but as the result is the same in both threads, it's ok
|
|
||||||
static GET_LONG_PATH_NAME s_pfnGetLongPathName = NULL;
|
|
||||||
if ( !s_pfnGetLongPathName )
|
|
||||||
{
|
{
|
||||||
static bool s_triedToLoad = false;
|
if ( ::GetLongPathName
|
||||||
|
(
|
||||||
if ( !s_triedToLoad )
|
path.t_str(),
|
||||||
|
wxStringBuffer(pathOut, dwSize),
|
||||||
|
dwSize
|
||||||
|
) != 0 )
|
||||||
{
|
{
|
||||||
s_triedToLoad = true;
|
return pathOut;
|
||||||
|
|
||||||
wxDynamicLibrary dllKernel(wxT("kernel32"));
|
|
||||||
|
|
||||||
const wxChar* GetLongPathName = wxT("GetLongPathName")
|
|
||||||
#if wxUSE_UNICODE
|
|
||||||
wxT("W");
|
|
||||||
#else // ANSI
|
|
||||||
wxT("A");
|
|
||||||
#endif // Unicode/ANSI
|
|
||||||
|
|
||||||
if ( dllKernel.HasSymbol(GetLongPathName) )
|
|
||||||
{
|
|
||||||
s_pfnGetLongPathName = (GET_LONG_PATH_NAME)
|
|
||||||
dllKernel.GetSymbol(GetLongPathName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// note that kernel32.dll can be unloaded, it stays in memory
|
|
||||||
// anyhow as all Win32 programs link to it and so it's safe to call
|
|
||||||
// GetLongPathName() even after unloading it
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( s_pfnGetLongPathName )
|
// Some other error occured.
|
||||||
{
|
|
||||||
DWORD dwSize = (*s_pfnGetLongPathName)(path.t_str(), NULL, 0);
|
|
||||||
if ( dwSize > 0 )
|
|
||||||
{
|
|
||||||
if ( (*s_pfnGetLongPathName)
|
|
||||||
(
|
|
||||||
path.t_str(),
|
|
||||||
wxStringBuffer(pathOut, dwSize),
|
|
||||||
dwSize
|
|
||||||
) != 0 )
|
|
||||||
{
|
|
||||||
return pathOut;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // wxUSE_DYNLIB_CLASS
|
|
||||||
|
|
||||||
// The OS didn't support GetLongPathName, or some other error.
|
|
||||||
// We need to call FindFirstFile on each component in turn.
|
// We need to call FindFirstFile on each component in turn.
|
||||||
|
|
||||||
WIN32_FIND_DATA findFileData;
|
WIN32_FIND_DATA findFileData;
|
||||||
|
Loading…
Reference in New Issue
Block a user