added GetPath(flags) version to allow retrieving the volume as well
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15032 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -374,17 +374,45 @@ convenience wrapper: get just the last mod time of the file
|
|||||||
|
|
||||||
\membersection{wxFileName::GetPath}\label{wxfilenamegetpath}
|
\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}
|
\membersection{wxFileName::GetPathSeparators}\label{wxfilenamegetpathseparators}
|
||||||
|
|
||||||
\func{wxString}{GetPathSeparators}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
|
\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}
|
\membersection{wxFileName::GetPathWithSep}\label{wxfilenamegetpathwithsep}
|
||||||
|
|
||||||
|
@@ -73,6 +73,13 @@ enum wxPathNormalize
|
|||||||
wxPATH_NORM_ALL = 0x003f
|
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
|
// wxFileName: encapsulates a file path
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -322,16 +329,12 @@ public:
|
|||||||
|
|
||||||
const wxArrayString& GetDirs() const { return m_dirs; }
|
const wxArrayString& GetDirs() const { return m_dirs; }
|
||||||
|
|
||||||
// Construct path only - possibly with the trailing separator
|
// flags are combination of wxPATH_GET_XXX flags
|
||||||
wxString GetPath( bool add_separator = FALSE,
|
wxString GetPath(int flags = 0, wxPathFormat format = wxPATH_NATIVE) const;
|
||||||
wxPathFormat format = wxPATH_NATIVE ) const;
|
|
||||||
// Replace current path with this one
|
// Replace current path with this one
|
||||||
void SetPath( const wxString &path, wxPathFormat format = wxPATH_NATIVE );
|
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
|
// Construct full path with name and ext
|
||||||
wxString GetFullPath( wxPathFormat format = wxPATH_NATIVE ) const;
|
wxString GetFullPath( wxPathFormat format = wxPATH_NATIVE ) const;
|
||||||
|
|
||||||
@@ -365,6 +368,16 @@ public:
|
|||||||
wxString *ext,
|
wxString *ext,
|
||||||
wxPathFormat format = wxPATH_NATIVE);
|
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:
|
private:
|
||||||
// the drive/volume/device specification (always empty for Unix)
|
// the drive/volume/device specification (always empty for Unix)
|
||||||
wxString m_volume;
|
wxString m_volume;
|
||||||
|
@@ -392,7 +392,7 @@ void wxFileName::Assign(const wxString& fullpathOrig,
|
|||||||
wxString fullpath = fullpathOrig;
|
wxString fullpath = fullpathOrig;
|
||||||
if ( !wxEndsWithPathSeparator(fullpath) )
|
if ( !wxEndsWithPathSeparator(fullpath) )
|
||||||
{
|
{
|
||||||
fullpath += GetPathSeparators(format)[0u];
|
fullpath += GetPathSeparator(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString volume, path, name, ext;
|
wxString volume, path, name, ext;
|
||||||
@@ -1128,26 +1128,33 @@ wxString wxFileName::GetFullName() const
|
|||||||
return fullname;
|
return fullname;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxFileName::GetPath( bool add_separator, wxPathFormat format ) const
|
wxString wxFileName::GetPath( int flags, wxPathFormat format ) const
|
||||||
{
|
{
|
||||||
format = GetFormat( format );
|
format = GetFormat( format );
|
||||||
|
|
||||||
wxString fullpath;
|
wxString fullpath;
|
||||||
|
|
||||||
// the leading character
|
// return the volume with the path as well if requested
|
||||||
if ( format == wxPATH_MAC && m_relative )
|
if ( flags & wxPATH_GET_VOLUME )
|
||||||
{
|
{
|
||||||
fullpath += wxFILE_SEP_PATH_MAC;
|
fullpath += wxGetVolumeString(GetVolume(), format);
|
||||||
|
}
|
||||||
|
|
||||||
|
// the leading character
|
||||||
|
if ( format == wxPATH_MAC )
|
||||||
|
{
|
||||||
|
if ( m_relative )
|
||||||
|
fullpath += wxFILE_SEP_PATH_MAC;
|
||||||
}
|
}
|
||||||
else if ( format == wxPATH_DOS )
|
else if ( format == wxPATH_DOS )
|
||||||
{
|
{
|
||||||
if (!m_relative)
|
if (!m_relative)
|
||||||
fullpath += wxFILE_SEP_PATH_DOS;
|
fullpath += wxFILE_SEP_PATH_DOS;
|
||||||
}
|
}
|
||||||
else if ( format == wxPATH_UNIX )
|
else if ( format == wxPATH_UNIX )
|
||||||
{
|
{
|
||||||
if (!m_relative)
|
if (!m_relative)
|
||||||
fullpath += wxFILE_SEP_PATH_UNIX;
|
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
|
||||||
@@ -1159,7 +1166,6 @@ wxString wxFileName::GetPath( bool add_separator, wxPathFormat format ) const
|
|||||||
fullpath += wxT('[');
|
fullpath += wxT('[');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for ( size_t i = 0; i < dirCount; i++ )
|
for ( size_t i = 0; i < dirCount; i++ )
|
||||||
{
|
{
|
||||||
// TODO: What to do with ".." under VMS
|
// TODO: What to do with ".." under VMS
|
||||||
@@ -1205,9 +1211,9 @@ wxString wxFileName::GetPath( bool add_separator, wxPathFormat format ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( add_separator && !fullpath.empty() )
|
if ( (flags & wxPATH_GET_SEPARATOR) && !fullpath.empty() )
|
||||||
{
|
{
|
||||||
fullpath += GetPathSeparators(format)[0u];
|
fullpath += GetPathSeparator(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fullpath;
|
return fullpath;
|
||||||
|
Reference in New Issue
Block a user