- wxString seps;
- if (format == wxPATH_DOS)
- {
- seps = "/\\";
- }
- else
- if (format == wxPATH_UNIX)
- {
- seps = "/";
- }
- else
- {
- seps = ":";
- }
-
- wxStringTokenizer tn( path, seps );
- while (tn.HasMoreTokens())
- {
- wxString token( tn.GetNextToken() );
- if (!token.IsEmpty())
- m_dirs.Add( token );
- }
-
- if (!dir_only)
- {
- // make last m_dir -> m_name
- size_t last = m_dirs.GetCount();
- if (last == 0) return;
- last--;
- m_name = m_dirs[last];
- m_dirs.Remove( last );
-
- if (m_name == wxT(".")) return;
- if (m_name == wxT("..")) return;
-
- // ext?
- int pos = m_name.Find( wxT('.') );
- if (pos == -1) return;
-
- bool has_starting_dot = (pos == 0);
- if (has_starting_dot && (format == wxPATH_UNIX))
- {
- // remove dot
- m_name.Remove(0,1);
-
- // search again
- pos = m_name.Find( wxT('.') );
- if (pos == -1)
- {
- // add dot back
- m_name.Prepend( "." );
- return;
- }
- }
- m_ext = m_name;
- m_ext.Remove( 0, pos+1 );
-
- m_name.Remove( pos, m_name.Len()-pos );
-
- if (has_starting_dot && (format == wxPATH_UNIX))
- {
- // add dot back
- m_name.Prepend( "." );
- return;
- }
- }