fix for mistakenly prepending slash to the filenames without paths (bug introduced by last check in)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24242 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1261,104 +1261,101 @@ wxString wxFileName::GetPath( int flags, wxPathFormat format ) const
|
|||||||
fullpath += wxGetVolumeString(GetVolume(), format);
|
fullpath += wxGetVolumeString(GetVolume(), format);
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t dirCount = m_dirs.GetCount();
|
// the leading character
|
||||||
if ( dirCount )
|
switch ( format )
|
||||||
{
|
{
|
||||||
// the leading character
|
case wxPATH_MAC:
|
||||||
switch ( format )
|
if ( m_relative )
|
||||||
|
fullpath += wxFILE_SEP_PATH_MAC;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxPATH_DOS:
|
||||||
|
if ( !m_relative )
|
||||||
|
fullpath += wxFILE_SEP_PATH_DOS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG( wxT("Unknown path format") );
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case wxPATH_UNIX:
|
||||||
|
if ( !m_relative )
|
||||||
|
{
|
||||||
|
// normally the absolute file names start with a slash
|
||||||
|
// with one exception: the ones like "~/foo.bar" don't
|
||||||
|
// have it
|
||||||
|
if ( 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_dirs.empty() )
|
||||||
|
{
|
||||||
|
// there is nothing more
|
||||||
|
return fullpath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// then concatenate all the path components using the path separator
|
||||||
|
if ( format == wxPATH_VMS )
|
||||||
|
{
|
||||||
|
fullpath += wxT('[');
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t dirCount = m_dirs.GetCount();
|
||||||
|
for ( size_t i = 0; i < dirCount; i++ )
|
||||||
|
{
|
||||||
|
switch (format)
|
||||||
{
|
{
|
||||||
case wxPATH_MAC:
|
case wxPATH_MAC:
|
||||||
if ( m_relative )
|
if ( m_dirs[i] == wxT(".") )
|
||||||
fullpath += wxFILE_SEP_PATH_MAC;
|
{
|
||||||
break;
|
// skip appending ':', this shouldn't be done in this
|
||||||
|
// case as "::" is interpreted as ".." under Unix
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
case wxPATH_DOS:
|
// convert back from ".." to nothing
|
||||||
if ( !m_relative )
|
if ( m_dirs[i] != wxT("..") )
|
||||||
fullpath += wxFILE_SEP_PATH_DOS;
|
fullpath += m_dirs[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( wxT("Unknown path format") );
|
wxFAIL_MSG( wxT("Unexpected path format") );
|
||||||
// fall through
|
// still fall through
|
||||||
|
|
||||||
|
case wxPATH_DOS:
|
||||||
case wxPATH_UNIX:
|
case wxPATH_UNIX:
|
||||||
if ( !m_relative )
|
fullpath += m_dirs[i];
|
||||||
{
|
|
||||||
// normally the absolute file names start with a slash
|
|
||||||
// with one exception: the ones like "~/foo.bar" don't
|
|
||||||
// have it
|
|
||||||
if ( m_dirs[0u] != _T('~') )
|
|
||||||
{
|
|
||||||
fullpath += wxFILE_SEP_PATH_UNIX;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxPATH_VMS:
|
case wxPATH_VMS:
|
||||||
// no leading character here but use this place to unset
|
// TODO: What to do with ".." under VMS
|
||||||
// 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
|
// convert back from ".." to nothing
|
||||||
if ( format == wxPATH_VMS )
|
if ( m_dirs[i] != wxT("..") )
|
||||||
{
|
|
||||||
fullpath += wxT('[');
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( size_t i = 0; i < dirCount; i++ )
|
|
||||||
{
|
|
||||||
switch (format)
|
|
||||||
{
|
|
||||||
case wxPATH_MAC:
|
|
||||||
if ( m_dirs[i] == wxT(".") )
|
|
||||||
{
|
|
||||||
// skip appending ':', this shouldn't be done in this
|
|
||||||
// case as "::" is interpreted as ".." under Unix
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert back from ".." to nothing
|
|
||||||
if ( m_dirs[i] != wxT("..") )
|
|
||||||
fullpath += m_dirs[i];
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
wxFAIL_MSG( wxT("Unexpected path format") );
|
|
||||||
// still fall through
|
|
||||||
|
|
||||||
case wxPATH_DOS:
|
|
||||||
case wxPATH_UNIX:
|
|
||||||
fullpath += m_dirs[i];
|
fullpath += m_dirs[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
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 ( (flags & wxPATH_GET_SEPARATOR) || (i != dirCount - 1) )
|
|
||||||
fullpath += GetPathSeparator(format);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( format == wxPATH_VMS )
|
if ( (flags & wxPATH_GET_SEPARATOR) || (i != dirCount - 1) )
|
||||||
{
|
|
||||||
fullpath += wxT(']');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // no directories
|
|
||||||
{
|
|
||||||
// still append path separator if requested
|
|
||||||
if ( flags & wxPATH_GET_SEPARATOR )
|
|
||||||
fullpath += GetPathSeparator(format);
|
fullpath += GetPathSeparator(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( format == wxPATH_VMS )
|
||||||
|
{
|
||||||
|
fullpath += wxT(']');
|
||||||
|
}
|
||||||
|
|
||||||
return fullpath;
|
return fullpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user