+ format = GetFormat(format);
+
+ wxString fullpath;
+
+ // first put the volume
+ if ( !m_volume.empty() )
+ {
+ {
+ // Special Windows UNC paths hack, part 2: undo what we did in
+ // SplitPath() and make an UNC path if we have a drive which is not a
+ // single letter (hopefully the network shares can't be one letter only
+ // although I didn't find any authoritative docs on this)
+ if ( format == wxPATH_DOS && m_volume.length() > 1 )
+ {
+ fullpath << wxFILE_SEP_PATH_DOS << wxFILE_SEP_PATH_DOS << m_volume;
+ }
+ else if ( format == wxPATH_DOS || format == wxPATH_VMS )
+ {
+ fullpath << m_volume << GetVolumeSeparator(format);
+ }
+ // else ignore
+ }
+ }
+
+ // the leading character
+ if ( format == wxPATH_MAC && m_relative )
+ {
+ fullpath += wxFILE_SEP_PATH_MAC;
+ }
+ else if ( format == wxPATH_DOS )
+ {
+ if (!m_relative)
+ fullpath += wxFILE_SEP_PATH_DOS;
+ }
+ else if ( format == wxPATH_UNIX )
+ {
+ if (!m_relative)
+ fullpath += wxFILE_SEP_PATH_UNIX;
+ }
+
+ // then concatenate all the path components using the path separator
+ size_t dirCount = m_dirs.GetCount();
+ if ( dirCount )
+ {
+ if ( format == wxPATH_VMS )
+ {
+ fullpath += wxT('[');
+ }
+
+
+ for ( size_t i = 0; i < dirCount; i++ )
+ {
+ // TODO: What to do with ".." under VMS
+
+ switch (format)
+ {
+ case wxPATH_MAC:
+ {
+ if (m_dirs[i] == wxT("."))
+ break;
+ if (m_dirs[i] != wxT("..")) // convert back from ".." to nothing
+ fullpath += m_dirs[i];
+ fullpath += wxT(':');
+ break;
+ }
+ case wxPATH_DOS:
+ {
+ fullpath += m_dirs[i];
+ fullpath += wxT('\\');
+ break;
+ }
+ case wxPATH_UNIX:
+ {
+ fullpath += m_dirs[i];
+ fullpath += wxT('/');
+ break;
+ }
+ case wxPATH_VMS:
+ {
+ if (m_dirs[i] != wxT("..")) // convert back from ".." to nothing
+ fullpath += m_dirs[i];
+ if (i == dirCount-1)
+ fullpath += wxT(']');
+ else
+ fullpath += wxT('.');
+ break;
+ }
+ default:
+ {
+ wxFAIL_MSG( wxT("error") );
+ }
+ }
+ }
+ }
+
+ // finally add the file name and extension
+ fullpath += GetFullName();
+
+ return fullpath;
+}
+
+// Return the short form of the path (returns identity on non-Windows platforms)
+wxString wxFileName::GetShortPath() const
+{
+#if defined(__WXMSW__) && defined(__WIN32__) && !defined(__WXMICROWIN__)
+ wxString path(GetFullPath());
+ wxString pathOut;
+ DWORD sz = ::GetShortPathName(path, NULL, 0);
+ bool ok = sz != 0;
+ if ( ok )
+ {
+ ok = ::GetShortPathName
+ (
+ path,
+ pathOut.GetWriteBuf(sz),
+ sz
+ ) != 0;
+ pathOut.UngetWriteBuf();
+ }
+ if (ok)
+ return pathOut;
+
+ return path;
+#else
+ return GetFullPath();
+#endif
+}
+
+// Return the long form of the path (returns identity on non-Windows platforms)
+wxString wxFileName::GetLongPath() const
+{
+ wxString pathOut,
+ path = GetFullPath();
+
+#if defined(__WIN32__) && !defined(__WXMICROWIN__)
+ bool success = FALSE;
+
+ // VZ: this code was disabled, why?
+#if 0 // wxUSE_DYNAMIC_LOADER
+ typedef DWORD (*GET_LONG_PATH_NAME)(const wxChar *, wxChar *, DWORD);
+
+ static bool s_triedToLoad = FALSE;
+
+ if ( !s_triedToLoad )
+ {
+ s_triedToLoad = TRUE;
+ wxDllType dllKernel = wxDllLoader::LoadLibrary(_T("kernel32"));
+ if ( dllKernel )
+ {
+ // may succeed or fail depending on the Windows version
+ static GET_LONG_PATH_NAME s_pfnGetLongPathName = NULL;
+#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);
+
+ if ( s_pfnGetLongPathName )
+ {
+ DWORD dwSize = (*s_pfnGetLongPathName)(path, NULL, 0);
+ bool ok = dwSize > 0;
+
+ if ( ok )
+ {
+ DWORD sz = (*s_pfnGetLongPathName)(path, NULL, 0);
+ ok = sz != 0;
+ if ( ok )
+ {
+ ok = (*s_pfnGetLongPathName)
+ (
+ path,
+ pathOut.GetWriteBuf(sz),
+ sz
+ ) != 0;
+ pathOut.UngetWriteBuf();
+
+ success = TRUE;
+ }
+ }
+ }
+ }
+ }
+ if (success)
+ return pathOut;
+#endif // wxUSE_DYNAMIC_LOADER
+
+ if (!success)
+ {
+ // The OS didn't support GetLongPathName, or some other error.
+ // We need to call FindFirstFile on each component in turn.
+
+ WIN32_FIND_DATA findFileData;
+ HANDLE hFind;
+ pathOut = wxEmptyString;
+
+ wxArrayString dirs = GetDirs();
+ dirs.Add(GetFullName());
+
+ wxString tmpPath;
+
+ size_t count = dirs.GetCount();
+ for ( size_t i = 0; i < count; i++ )
+ {
+ // We're using pathOut to collect the long-name path, but using a
+ // temporary for appending the last path component which may be
+ // short-name
+ tmpPath = pathOut + dirs[i];
+
+ if ( tmpPath.empty() )
+ continue;
+
+ if ( tmpPath.Last() == wxT(':') )
+ {
+ // Can't pass a drive and root dir to FindFirstFile,
+ // so continue to next dir
+ tmpPath += wxFILE_SEP_PATH;
+ pathOut = tmpPath;
+ continue;
+ }
+
+ hFind = ::FindFirstFile(tmpPath, &findFileData);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ // Error: return immediately with the original path
+ return path;
+ }
+
+ pathOut += findFileData.cFileName;
+ if ( (i < (count-1)) )
+ pathOut += wxFILE_SEP_PATH;
+
+ ::FindClose(hFind);
+ }
+ }
+#else // !Win32
+ pathOut = path;
+#endif // Win32/!Win32
+
+ return pathOut;