fixed Assign(fullpath, fullname)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12852 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
a8e6bf8ae2
commit
81f256328c
@ -173,7 +173,11 @@ Constructor from a directory name and a file name.
|
||||
|
||||
\func{}{wxFileName}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
|
||||
|
||||
Constructor from a directory name, file base name and extension
|
||||
Constructor from a directory name, base file name and extension
|
||||
|
||||
\func{}{wxFileName}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
|
||||
|
||||
Constructor from a volume name, a directory name, base file name and extension
|
||||
|
||||
\membersection{wxFileName::AppendDir}\label{wxfilenameappenddir}
|
||||
|
||||
@ -208,15 +212,14 @@ volume (or current volume if {\it volume} is empty).
|
||||
|
||||
\func{void}{AssignDir}{\param{const wxString\& }{dir}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
|
||||
|
||||
empty volume
|
||||
|
||||
Set this file name object to the given directory name. The name and extension
|
||||
will be empty.
|
||||
|
||||
\membersection{wxFileName::AssignHomeDir}\label{wxfilenameassignhomedir}
|
||||
|
||||
\func{void}{AssignHomeDir}{\void}
|
||||
|
||||
get the value of user home (Unix only mainly)
|
||||
|
||||
Set this file name object to the home directory.
|
||||
|
||||
\membersection{wxFileName::AssignTempFileName}\label{wxfilenameassigntempfilename}
|
||||
|
||||
|
@ -96,6 +96,14 @@ public:
|
||||
wxPathFormat format = wxPATH_NATIVE)
|
||||
{ Assign(path, name, format); }
|
||||
|
||||
// from a volume, directory name, file base name and extension
|
||||
wxFileName(const wxString& volume,
|
||||
const wxString& path,
|
||||
const wxString& name,
|
||||
const wxString& ext,
|
||||
wxPathFormat format = wxPATH_NATIVE)
|
||||
{ Assign(volume, path, name, ext, format); }
|
||||
|
||||
// from a directory name, file base name and extension
|
||||
wxFileName(const wxString& path,
|
||||
const wxString& name,
|
||||
|
@ -740,6 +740,17 @@ static void TestFileConfRead()
|
||||
|
||||
#include "wx/filename.h"
|
||||
|
||||
static void DumpFileName(const wxFileName& fn)
|
||||
{
|
||||
wxString full = fn.GetFullPath();
|
||||
|
||||
wxString vol, path, name, ext;
|
||||
wxFileName::SplitPath(full, &vol, &path, &name, &ext);
|
||||
|
||||
wxPrintf(_T("Filename '%s' -> vol '%s', path '%s', name '%s', ext '%s'\n"),
|
||||
full.c_str(), vol.c_str(), path.c_str(), name.c_str(), ext.c_str());
|
||||
}
|
||||
|
||||
static struct FileNameInfo
|
||||
{
|
||||
const wxChar *fullname;
|
||||
@ -5216,11 +5227,19 @@ int main(int argc, char **argv)
|
||||
#endif // TEST_FILE
|
||||
|
||||
#ifdef TEST_FILENAME
|
||||
TestFileNameTemp();
|
||||
if ( 0 )
|
||||
{
|
||||
wxFileName fn;
|
||||
fn.Assign("c:\\foo", "bar.baz");
|
||||
|
||||
DumpFileName(fn);
|
||||
}
|
||||
|
||||
if ( 0 )
|
||||
{
|
||||
TestFileNameConstruction();
|
||||
TestFileNameSplit();
|
||||
TestFileNameTemp();
|
||||
TestFileNameCwd();
|
||||
TestFileNameComparison();
|
||||
TestFileNameOperations();
|
||||
|
@ -247,27 +247,46 @@ void wxFileName::Assign(const wxString& fullpath,
|
||||
Assign(volume, path, name, ext, format);
|
||||
}
|
||||
|
||||
void wxFileName::Assign(const wxString& fullpath,
|
||||
void wxFileName::Assign(const wxString& fullpathOrig,
|
||||
const wxString& fullname,
|
||||
wxPathFormat format)
|
||||
{
|
||||
// always recognize fullpath as directory, even if it doesn't end with a
|
||||
// slash
|
||||
wxString fullpath = fullpathOrig;
|
||||
if ( !wxEndsWithPathSeparator(fullpath) )
|
||||
{
|
||||
fullpath += GetPathSeparators(format)[0u];
|
||||
}
|
||||
|
||||
wxString volume, path, name, ext;
|
||||
|
||||
// do some consistency checks in debug mode: the name should be really just
|
||||
// the filename and the path should be realyl just a path
|
||||
#ifdef __WXDEBUG__
|
||||
wxString pathDummy, nameDummy, extDummy;
|
||||
|
||||
SplitPath(fullname, &pathDummy, &name, &ext, format);
|
||||
|
||||
wxASSERT_MSG( pathDummy.empty(),
|
||||
_T("the file name shouldn't contain the path") );
|
||||
|
||||
SplitPath(fullpath, &volume, &path, &nameDummy, &extDummy, format);
|
||||
|
||||
wxASSERT_MSG( nameDummy.empty() && extDummy.empty(),
|
||||
_T("the path shouldn't contain file name nor extension") );
|
||||
|
||||
#else // !__WXDEBUG__
|
||||
SplitPath(fullname, NULL /* no path */, &name, &ext, format);
|
||||
SplitPath(fullpath, &volume, &path, NULL, NULL, format);
|
||||
#endif // __WXDEBUG__/!__WXDEBUG__
|
||||
|
||||
Assign(volume, path, name, ext, format);
|
||||
}
|
||||
|
||||
void wxFileName::AssignDir(const wxString& dir, wxPathFormat format)
|
||||
{
|
||||
// always recognize dir as directory, even if it doesn't end with a slash
|
||||
wxString dirname = dir;
|
||||
if ( !wxEndsWithPathSeparator(dirname) )
|
||||
{
|
||||
dirname += GetPathSeparators(format)[0u];
|
||||
}
|
||||
|
||||
Assign(dirname, _T(""), format);
|
||||
Assign(dir, _T(""), format);
|
||||
}
|
||||
|
||||
void wxFileName::Clear()
|
||||
|
Loading…
Reference in New Issue
Block a user