Corrections to the GetLongPath code
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9582 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -37,7 +37,10 @@
|
|||||||
#include "wx/tokenzr.h"
|
#include "wx/tokenzr.h"
|
||||||
#include "wx/config.h" // for wxExpandEnvVars
|
#include "wx/config.h" // for wxExpandEnvVars
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
|
|
||||||
|
#if wxUSE_DYNLIB_CLASS
|
||||||
#include "wx/dynlib.h"
|
#include "wx/dynlib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// For GetShort/LongPathName
|
// For GetShort/LongPathName
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
@@ -524,6 +527,7 @@ wxString wxFileName::GetLongPath() const
|
|||||||
wxString pathOut;
|
wxString pathOut;
|
||||||
bool success = FALSE;
|
bool success = FALSE;
|
||||||
|
|
||||||
|
#if wxUSE_DYNLIB_CLASS
|
||||||
typedef DWORD (*GET_LONG_PATH_NAME)(const wxChar *, wxChar *, DWORD);
|
typedef DWORD (*GET_LONG_PATH_NAME)(const wxChar *, wxChar *, DWORD);
|
||||||
|
|
||||||
static bool s_triedToLoad = FALSE;
|
static bool s_triedToLoad = FALSE;
|
||||||
@@ -534,10 +538,14 @@ wxString wxFileName::GetLongPath() const
|
|||||||
s_triedToLoad = TRUE;
|
s_triedToLoad = TRUE;
|
||||||
|
|
||||||
wxDllType dllKernel = wxDllLoader::LoadLibrary(_T("kernel32"));
|
wxDllType dllKernel = wxDllLoader::LoadLibrary(_T("kernel32"));
|
||||||
if ( dllKernel )
|
if ( 0 ) // dllKernel )
|
||||||
{
|
{
|
||||||
// may succeed or fail depending on the Windows version
|
// may succeed or fail depending on the Windows version
|
||||||
s_pfnGetLongPathName = (GET_LONG_PATH_NAME) wxDllLoader::GetSymbol(dllKernel, _T("GetLongPathName"));
|
#ifdef _UNICODE
|
||||||
|
s_pfnGetLongPathName = (GET_LONG_PATH_NAME) wxDllLoader::GetSymbol(dllKernel, _T("GetLongPathNameW"));
|
||||||
|
#else
|
||||||
|
s_pfnGetLongPathName = (GET_LONG_PATH_NAME) wxDllLoader::GetSymbol(dllKernel, _T("GetLongPathNameA"));
|
||||||
|
#endif
|
||||||
|
|
||||||
wxDllLoader::UnloadLibrary(dllKernel);
|
wxDllLoader::UnloadLibrary(dllKernel);
|
||||||
|
|
||||||
@@ -568,6 +576,8 @@ wxString wxFileName::GetLongPath() const
|
|||||||
}
|
}
|
||||||
if (success)
|
if (success)
|
||||||
return pathOut;
|
return pathOut;
|
||||||
|
#endif
|
||||||
|
// wxUSE_DYNLIB_CLASS
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
@@ -581,6 +591,7 @@ wxString wxFileName::GetLongPath() const
|
|||||||
size_t count = m_dirs.GetCount();
|
size_t count = m_dirs.GetCount();
|
||||||
size_t i;
|
size_t i;
|
||||||
wxString tmpPath;
|
wxString tmpPath;
|
||||||
|
|
||||||
for ( i = 0; i < count; i++ )
|
for ( i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
// We're using pathOut to collect the long-name path,
|
// We're using pathOut to collect the long-name path,
|
||||||
@@ -588,7 +599,13 @@ wxString wxFileName::GetLongPath() const
|
|||||||
tmpPath = pathOut + m_dirs[i];
|
tmpPath = pathOut + m_dirs[i];
|
||||||
|
|
||||||
if (tmpPath.Last() == wxT(':'))
|
if (tmpPath.Last() == wxT(':'))
|
||||||
|
{
|
||||||
|
// Can't pass a drive and root dir to FindFirstFile,
|
||||||
|
// so continue to next dir
|
||||||
tmpPath += wxFILE_SEP_PATH;
|
tmpPath += wxFILE_SEP_PATH;
|
||||||
|
pathOut = tmpPath;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
hFind = ::FindFirstFile(tmpPath, &findFileData);
|
hFind = ::FindFirstFile(tmpPath, &findFileData);
|
||||||
if (hFind == INVALID_HANDLE_VALUE)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
@@ -599,7 +616,7 @@ wxString wxFileName::GetLongPath() const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
pathOut += findFileData.cFileName;
|
pathOut += findFileData.cFileName;
|
||||||
if ( (i < count) )
|
if ( (i < (count-1)) )
|
||||||
pathOut += wxFILE_SEP_PATH;
|
pathOut += wxFILE_SEP_PATH;
|
||||||
|
|
||||||
::FindClose(hFind);
|
::FindClose(hFind);
|
||||||
|
Reference in New Issue
Block a user