\membersection{wxFileName::GetPath}\label{wxfilenamegetpath}
-\constfunc{wxString}{GetPath}{\param{bool }{add\_separator = FALSE}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
+\constfunc{wxString}{GetPath}{\param{int }{flags = $0$}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
-Construct path only - possibly with the trailing separator
+Return the path part of the filename (without the name nor extension). The
+possible flags values are:
+\twocolwidtha{5cm}%
+\begin{twocollist}\itemsep=0pt
+\twocolitem{\tt wxPATH\_GET\_VOLUME}{Return the path with the volume (does
+nothing for the filename formats without volumes)}
+\twocolitem{\tt wxPATH\_GET\_SEPARATOR}{Return the path with the trailing
+separator, if this flag is not given there will be no separator at the end of
+the path.}
+\end{twocollist}
+
+\membersection{wxFileName::GetPathSeparator}\label{wxfilenamegetpathseparator}
+
+\func{wxChar}{GetPathSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
+
+Return the usually used path separator for this format. For all formats but
+{\tt wxPATH\_DOS} there is only one path separator anyhow, but for DOS there
+are two of them and the native one, i.e. the backslash is returned by this
+method.
+
+\wxheading{See also}
+
+\helpref{GetPathSeparators}{wxfilenamegetpathseparators}
\membersection{wxFileName::GetPathSeparators}\label{wxfilenamegetpathseparators}
\func{wxString}{GetPathSeparators}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
-get the string of path separators for this format
+Get the string containing all the path separators for this format. For all
+formats but {\tt wxPATH\_DOS} this string contains only one character but for
+DOS and Windows both {\tt '/'} and {\tt '\backslash'} may be used as
+separators.
+
+\wxheading{See also}
+\helpref{GetPathSeparator}{wxfilenamegetpathseparator}
\membersection{wxFileName::GetPathWithSep}\label{wxfilenamegetpathwithsep}
wxPATH_NORM_ALL = 0x003f
};
+// what exactly should GetPath() return?
+enum
+{
+ wxPATH_GET_VOLUME = 0x0001, // include the volume if applicable
+ wxPATH_GET_SEPARATOR = 0x0002 // terminate the path with the separator
+};
+
// ----------------------------------------------------------------------------
// wxFileName: encapsulates a file path
// ----------------------------------------------------------------------------
const wxArrayString& GetDirs() const { return m_dirs; }
- // Construct path only - possibly with the trailing separator
- wxString GetPath( bool add_separator = FALSE,
- wxPathFormat format = wxPATH_NATIVE ) const;
+ // flags are combination of wxPATH_GET_XXX flags
+ wxString GetPath(int flags = 0, wxPathFormat format = wxPATH_NATIVE) const;
+
// Replace current path with this one
void SetPath( const wxString &path, wxPathFormat format = wxPATH_NATIVE );
- // more readable synonym
- wxString GetPathWithSep(wxPathFormat format = wxPATH_NATIVE ) const
- { return GetPath(TRUE /* add separator */, format); }
-
// Construct full path with name and ext
wxString GetFullPath( wxPathFormat format = wxPATH_NATIVE ) const;
wxString *ext,
wxPathFormat format = wxPATH_NATIVE);
+
+ // deprecated methods, don't use any more
+ // --------------------------------------
+
+ wxString GetPath( bool withSep, wxPathFormat format = wxPATH_NATIVE ) const
+ { return GetPath(withSep ? wxPATH_GET_SEPARATOR : 0, format); }
+
+ wxString GetPathWithSep(wxPathFormat format = wxPATH_NATIVE ) const
+ { return GetPath(wxPATH_GET_SEPARATOR, format); }
+
private:
// the drive/volume/device specification (always empty for Unix)
wxString m_volume;
wxString fullpath = fullpathOrig;
if ( !wxEndsWithPathSeparator(fullpath) )
{
- fullpath += GetPathSeparators(format)[0u];
+ fullpath += GetPathSeparator(format);
}
wxString volume, path, name, ext;
return fullname;
}
-wxString wxFileName::GetPath( bool add_separator, wxPathFormat format ) const
+wxString wxFileName::GetPath( int flags, wxPathFormat format ) const
{
format = GetFormat( format );
wxString fullpath;
+ // return the volume with the path as well if requested
+ if ( flags & wxPATH_GET_VOLUME )
+ {
+ fullpath += wxGetVolumeString(GetVolume(), format);
+ }
+
// the leading character
- if ( format == wxPATH_MAC && m_relative )
+ if ( format == wxPATH_MAC )
{
- fullpath += wxFILE_SEP_PATH_MAC;
+ if ( m_relative )
+ fullpath += wxFILE_SEP_PATH_MAC;
}
else if ( format == wxPATH_DOS )
{
- if (!m_relative)
- fullpath += wxFILE_SEP_PATH_DOS;
+ if (!m_relative)
+ fullpath += wxFILE_SEP_PATH_DOS;
}
else if ( format == wxPATH_UNIX )
{
- if (!m_relative)
- fullpath += wxFILE_SEP_PATH_UNIX;
+ if (!m_relative)
+ fullpath += wxFILE_SEP_PATH_UNIX;
}
// then concatenate all the path components using the path separator
fullpath += wxT('[');
}
-
for ( size_t i = 0; i < dirCount; i++ )
{
// TODO: What to do with ".." under VMS
}
}
- if ( add_separator && !fullpath.empty() )
+ if ( (flags & wxPATH_GET_SEPARATOR) && !fullpath.empty() )
{
- fullpath += GetPathSeparators(format)[0u];
+ fullpath += GetPathSeparator(format);
}
return fullpath;