fixed 2 bugs which were fixed in GetFullPath() but not GetPath() and which were broken by the last commit

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15097 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-04-11 18:41:48 +00:00
parent 6aa3ea889a
commit 0ea621cc25

View File

@@ -146,7 +146,7 @@ public:
m_hFile = ::CreateFile m_hFile = ::CreateFile
( (
filename, // name filename, // name
mode == Read ? GENERIC_READ // access mask mode == Read ? GENERIC_READ // access mask
: GENERIC_WRITE, : GENERIC_WRITE,
0, // no sharing 0, // no sharing
NULL, // no secutity attr NULL, // no secutity attr
@@ -415,7 +415,7 @@ void wxFileName::Assign(const wxString& fullpathOrig,
_T("the path shouldn't contain file name nor extension") ); _T("the path shouldn't contain file name nor extension") );
#else // !__WXDEBUG__ #else // !__WXDEBUG__
SplitPath(fullname, NULL /* no path */, &name, &ext, format); SplitPath(fullname, NULL /* no path */, &name, &ext, format);
SplitPath(fullpath, &volume, &path, NULL, NULL, format); SplitPath(fullpath, &volume, &path, NULL, NULL, format);
#endif // __WXDEBUG__/!__WXDEBUG__ #endif // __WXDEBUG__/!__WXDEBUG__
@@ -751,10 +751,10 @@ bool wxFileName::Mkdir( const wxString& dir, int perm, int flags )
filename.AssignDir(dir); filename.AssignDir(dir);
wxString currPath; wxString currPath;
if ( filename.HasVolume()) if ( filename.HasVolume())
{ {
currPath << wxGetVolumeString(filename.GetVolume(), wxPATH_NATIVE); currPath << wxGetVolumeString(filename.GetVolume(), wxPATH_NATIVE);
} }
wxArrayString dirs = filename.GetDirs(); wxArrayString dirs = filename.GetDirs();
size_t count = dirs.GetCount(); size_t count = dirs.GetCount();
@@ -991,7 +991,7 @@ bool wxFileName::MakeRelativeTo(const wxString& pathBase, wxPathFormat format)
if ( m_dirs.IsEmpty() && IsDir() ) if ( m_dirs.IsEmpty() && IsDir() )
{ {
m_dirs.Add(_T('.')); m_dirs.Add(_T('.'));
} }
} }
m_relative = TRUE; m_relative = TRUE;
@@ -1156,8 +1156,15 @@ wxString wxFileName::GetPath( int flags, wxPathFormat format ) const
} }
else if ( format == wxPATH_UNIX ) else if ( format == wxPATH_UNIX )
{ {
if (!m_relative) 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;
}
}
} }
// then concatenate all the path components using the path separator // then concatenate all the path components using the path separator
@@ -1174,9 +1181,15 @@ wxString wxFileName::GetPath( int flags, wxPathFormat format ) const
switch (format) switch (format)
{ {
case wxPATH_MAC: case wxPATH_MAC:
if (m_dirs[i] == wxT(".")) if ( m_dirs[i] == wxT(".") )
break; {
if (m_dirs[i] != wxT("..")) // convert back from ".." to nothing // 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]; fullpath += m_dirs[i];
break; break;
@@ -1191,7 +1204,8 @@ wxString wxFileName::GetPath( int flags, wxPathFormat format ) const
case wxPATH_VMS: case wxPATH_VMS:
// TODO: What to do with ".." under VMS // TODO: What to do with ".." under VMS
if (m_dirs[i] != wxT("..")) // convert back from ".." to nothing // convert back from ".." to nothing
if ( m_dirs[i] != wxT("..") )
fullpath += m_dirs[i]; fullpath += m_dirs[i];
break; break;
} }
@@ -1698,18 +1712,18 @@ static void MacEnsureDefaultExtensionsLoaded()
MacDefaultExtensionRecord defaults[] = MacDefaultExtensionRecord defaults[] =
{ {
{ "txt" , 'TEXT' , 'ttxt' } , { "txt" , 'TEXT' , 'ttxt' } ,
} ; } ;
// we could load the pc exchange prefs here too // we could load the pc exchange prefs here too
for ( int i = 0 ; i < WXSIZEOF( defaults ) ; ++i ) for ( int i = 0 ; i < WXSIZEOF( defaults ) ; ++i )
{ {
gMacDefaultExtensions.Add( defaults[i] ) ; gMacDefaultExtensions.Add( defaults[i] ) ;
} }
gMacDefaultExtensionsInited = true ; gMacDefaultExtensionsInited = true ;
} }
} }
bool wxFileName::MacSetTypeAndCreator( wxUint32 type , wxUint32 creator ) bool wxFileName::MacSetTypeAndCreator( wxUint32 type , wxUint32 creator )
{ {
FInfo fndrInfo ; FInfo fndrInfo ;
FSSpec spec ; FSSpec spec ;
@@ -1723,7 +1737,7 @@ bool wxFileName::MacSetTypeAndCreator( wxUint32 type , wxUint32 creator )
return true ; return true ;
} }
bool wxFileName::MacGetTypeAndCreator( wxUint32 *type , wxUint32 *creator ) bool wxFileName::MacGetTypeAndCreator( wxUint32 *type , wxUint32 *creator )
{ {
FInfo fndrInfo ; FInfo fndrInfo ;
FSSpec spec ; FSSpec spec ;
@@ -1747,7 +1761,7 @@ bool wxFileName::MacSetDefaultTypeAndCreator()
return false; return false;
} }
bool wxFileName::MacFindDefaultTypeAndCreator( const wxString& ext , wxUint32 *type , wxUint32 *creator ) bool wxFileName::MacFindDefaultTypeAndCreator( const wxString& ext , wxUint32 *type , wxUint32 *creator )
{ {
MacEnsureDefaultExtensionsLoaded() ; MacEnsureDefaultExtensionsLoaded() ;
wxString extl = ext.Lower() ; wxString extl = ext.Lower() ;