X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0ca4ae936b3c1dbc276947001e8b660c6d29f477..42a3aedbcee394eba28bc8bd1e9400f1efc42ef8:/src/common/filename.cpp diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 06dca4aa49..05a84579cf 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -912,6 +912,11 @@ bool wxFileName::Normalize(int flags, m_ext.MakeLower(); } + // we do have the path now + // + // NB: need to do this before (maybe) calling Assign() below + m_relative = FALSE; + #if defined(__WIN32__) if ( (flags & wxPATH_NORM_LONG) && (format == wxPATH_DOS) ) { @@ -919,9 +924,6 @@ bool wxFileName::Normalize(int flags, } #endif // Win32 - // we do have the path now - m_relative = FALSE; - return TRUE; } @@ -1144,27 +1146,40 @@ wxString wxFileName::GetPath( int flags, wxPathFormat format ) const } // the leading character - if ( format == wxPATH_MAC ) - { - if ( m_relative ) - fullpath += wxFILE_SEP_PATH_MAC; - } - else if ( format == wxPATH_DOS ) + switch ( format ) { - if (!m_relative) - fullpath += wxFILE_SEP_PATH_DOS; - } - else if ( format == wxPATH_UNIX ) - { - if ( !m_relative ) - { - // normally the absolute file names starts with a slash with one - // exception: file names like "~/foo.bar" don't have it - if ( m_dirs.IsEmpty() || m_dirs[0u] != _T('~') ) + case wxPATH_MAC: + if ( m_relative ) + fullpath += wxFILE_SEP_PATH_MAC; + break; + + case wxPATH_DOS: + if (!m_relative) + fullpath += wxFILE_SEP_PATH_DOS; + break; + + default: + wxFAIL_MSG( _T("unknown path format") ); + // fall through + + case wxPATH_UNIX: + if ( !m_relative ) { - fullpath += wxFILE_SEP_PATH_UNIX; + // normally the absolute file names starts with a slash with + // one exception: file names like "~/foo.bar" don't have it + if ( m_dirs.IsEmpty() || m_dirs[0u] != _T('~') ) + { + fullpath += wxFILE_SEP_PATH_UNIX; + } } - } + break; + + case wxPATH_VMS: + // no leading character here but use this place to unset + // wxPATH_GET_SEPARATOR flag: under VMS it doesn't make sense as, + // if I understand correctly, there should never be a dot before + // the closing bracket + flags &= ~wxPATH_GET_SEPARATOR; } // then concatenate all the path components using the path separator @@ -1204,13 +1219,14 @@ wxString wxFileName::GetPath( int flags, wxPathFormat format ) const case wxPATH_VMS: // TODO: What to do with ".." under VMS + // convert back from ".." to nothing if ( m_dirs[i] != wxT("..") ) fullpath += m_dirs[i]; break; } - if ( i != dirCount - 1 ) + if ( (flags & wxPATH_GET_SEPARATOR) || (i != dirCount - 1) ) fullpath += GetPathSeparator(format); } @@ -1220,11 +1236,6 @@ wxString wxFileName::GetPath( int flags, wxPathFormat format ) const } } - if ( (flags & wxPATH_GET_SEPARATOR) && !fullpath.empty() && fullpath.Last() != GetPathSeparator(format)) - { - fullpath += GetPathSeparator(format); - } - return fullpath; } @@ -1283,6 +1294,9 @@ wxString wxFileName::GetLongPath() const if ( !s_triedToLoad ) { + // suppress the errors about missing GetLongPathName[AW] + wxLogNull noLog; + s_triedToLoad = TRUE; wxDynamicLibrary dllKernel(_T("kernel32")); if ( dllKernel.IsLoaded() ) @@ -1320,6 +1334,7 @@ wxString wxFileName::GetLongPath() const } } } + if (success) return pathOut; #endif // wxUSE_DYNAMIC_LOADER