- // if the path starts with a slash, we do need the first empty dir
- // entry to be able to tell later that it was an absolute path, but
- // otherwise ignore the double slashes
- if ( m_dirs.IsEmpty() || !token.IsEmpty() )
- m_dirs.Add( token );
+ switch (my_format)
+ {
+ case wxPATH_MAC:
+ m_relative = ( my_path[0u] == wxT(':') );
+ // We then remove a leading ":". The reason is in our
+ // storage form for relative paths:
+ // ":dir:file.txt" actually means "./dir/file.txt" in
+ // DOS notation and should get stored as
+ // (relative) (dir) (file.txt)
+ // "::dir:file.txt" actually means "../dir/file.txt"
+ // stored as (relative) (..) (dir) (file.txt)
+ // This is important only for the Mac as an empty dir
+ // actually means <UP>, whereas under DOS, double
+ // slashes can be ignored: "\\\\" is the same as "\\".
+ if (m_relative)
+ my_path.Remove( 0, 1 );
+ break;
+ case wxPATH_VMS:
+ // TODO: what is the relative path format here?
+ m_relative = FALSE;
+ break;
+ case wxPATH_UNIX:
+ m_relative = ( my_path[0u] != wxT('/') );
+ break;
+ case wxPATH_DOS:
+ m_relative = ( (my_path[0u] != wxT('/')) && (my_path[0u] != wxT('\\')) );
+ break;
+ default:
+ wxFAIL_MSG( wxT("error") );
+ break;
+ }
+
+ // 2) Break up the path into its members. If the original path
+ // was just "/" or "\\", m_dirs will be empty. We know from
+ // the m_relative field, if this means "nothing" or "root dir".
+
+ wxStringTokenizer tn( my_path, GetPathSeparators(my_format) );
+
+ while ( tn.HasMoreTokens() )
+ {
+ wxString token = tn.GetNextToken();
+
+ // Remove empty token under DOS and Unix, interpret them
+ // as .. under Mac.
+ if (token.empty())
+ {
+ if (my_format == wxPATH_MAC)
+ m_dirs.Add( wxT("..") );
+ // else ignore
+ }
+ else
+ {
+ m_dirs.Add( token );
+ }
+ }