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 wxUSE_DYNLIB_CLASS
|
||||
typedef DWORD (WINAPI *GET_LONG_PATH_NAME)(const wxChar *, wxChar *, DWORD);
|
||||
|
||||
// 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 )
|
||||
DWORD dwSize = ::GetLongPathName(path.t_str(), NULL, 0);
|
||||
if ( dwSize > 0 )
|
||||
{
|
||||
static bool s_triedToLoad = false;
|
||||
|
||||
if ( !s_triedToLoad )
|
||||
if ( ::GetLongPathName
|
||||
(
|
||||
path.t_str(),
|
||||
wxStringBuffer(pathOut, dwSize),
|
||||
dwSize
|
||||
) != 0 )
|
||||
{
|
||||
s_triedToLoad = true;
|
||||
|
||||
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
|
||||
return pathOut;
|
||||
}
|
||||
}
|
||||
|
||||
if ( s_pfnGetLongPathName )
|
||||
{
|
||||
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.
|
||||
// Some other error occured.
|
||||
// We need to call FindFirstFile on each component in turn.
|
||||
|
||||
WIN32_FIND_DATA findFileData;
|
||||
|
Loading…
Reference in New Issue
Block a user