Use wxFileName::MakeAbsolute() instead of Normalize()
Make the code more clear by being more explicit about what it does. No real changes and no changes in behaviour at all.
This commit is contained in:
@@ -361,7 +361,7 @@ public:
|
|||||||
bool MakeRelativeTo(const wxString& pathBase = wxEmptyString,
|
bool MakeRelativeTo(const wxString& pathBase = wxEmptyString,
|
||||||
wxPathFormat format = wxPATH_NATIVE);
|
wxPathFormat format = wxPATH_NATIVE);
|
||||||
|
|
||||||
// make the path absolute
|
// make the path absolute and resolve any "." and ".." in it
|
||||||
//
|
//
|
||||||
// this may be done using another (than current) value of cwd
|
// this may be done using another (than current) value of cwd
|
||||||
bool MakeAbsolute(const wxString& cwd = wxEmptyString,
|
bool MakeAbsolute(const wxString& cwd = wxEmptyString,
|
||||||
|
@@ -575,15 +575,15 @@ MyFrame::MyFrame()
|
|||||||
m_fileHistory->UseMenu(m_fileHistoryMenu);
|
m_fileHistory->UseMenu(m_fileHistoryMenu);
|
||||||
|
|
||||||
wxFileName fn( "menu.cpp" );
|
wxFileName fn( "menu.cpp" );
|
||||||
fn.Normalize();
|
fn.MakeAbsolute();
|
||||||
m_fileHistory->AddFileToHistory( fn.GetFullPath() );
|
m_fileHistory->AddFileToHistory( fn.GetFullPath() );
|
||||||
|
|
||||||
fn = "Makefile.in";
|
fn = "Makefile.in";
|
||||||
fn.Normalize();
|
fn.MakeAbsolute();
|
||||||
m_fileHistory->AddFileToHistory( fn.GetFullPath() );
|
m_fileHistory->AddFileToHistory( fn.GetFullPath() );
|
||||||
|
|
||||||
fn.Assign("minimal", "minimal", "cpp");
|
fn.Assign("minimal", "minimal", "cpp");
|
||||||
fn.Normalize();
|
fn.MakeAbsolute();
|
||||||
m_fileHistory->AddFileToHistory( fn.GetFullPath() );
|
m_fileHistory->AddFileToHistory( fn.GetFullPath() );
|
||||||
|
|
||||||
fileMenu->AppendSubMenu(m_fileHistoryMenu, "Sample file history");
|
fileMenu->AppendSubMenu(m_fileHistoryMenu, "Sample file history");
|
||||||
|
@@ -1765,14 +1765,14 @@ bool wxFileName::MakeRelativeTo(const wxString& pathBase, wxPathFormat format)
|
|||||||
// get cwd only once - small time saving
|
// get cwd only once - small time saving
|
||||||
wxString cwd = wxGetCwd();
|
wxString cwd = wxGetCwd();
|
||||||
|
|
||||||
// Normalize both paths to be absolute but avoid expanding environment
|
// Bring both paths to canonical form.
|
||||||
// variables in them, this could be unexpected.
|
MakeAbsolute(cwd, format);
|
||||||
const int normFlags = wxPATH_NORM_DOTS |
|
fnBase.MakeAbsolute(cwd, format);
|
||||||
wxPATH_NORM_TILDE |
|
|
||||||
wxPATH_NORM_ABSOLUTE |
|
// Do this here for compatibility, as we used to do it before.
|
||||||
wxPATH_NORM_LONG;
|
Normalize(wxPATH_NORM_LONG, cwd, format);
|
||||||
Normalize(normFlags, cwd, format);
|
fnBase.Normalize(wxPATH_NORM_LONG, cwd, format);
|
||||||
fnBase.Normalize(normFlags, cwd, format);
|
|
||||||
|
|
||||||
bool withCase = IsCaseSensitive(format);
|
bool withCase = IsCaseSensitive(format);
|
||||||
|
|
||||||
@@ -2620,7 +2620,7 @@ static wxString EscapeFileNameCharsInURL(const char *in)
|
|||||||
wxString wxFileName::FileNameToURL(const wxFileName& filename)
|
wxString wxFileName::FileNameToURL(const wxFileName& filename)
|
||||||
{
|
{
|
||||||
wxFileName fn = filename;
|
wxFileName fn = filename;
|
||||||
fn.Normalize(wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_ABSOLUTE);
|
fn.MakeAbsolute();
|
||||||
wxString url = fn.GetFullPath(wxPATH_NATIVE);
|
wxString url = fn.GetFullPath(wxPATH_NATIVE);
|
||||||
|
|
||||||
#ifndef __UNIX__
|
#ifndef __UNIX__
|
||||||
|
@@ -201,8 +201,8 @@ TEST_CASE("wxFileName::Comparison", "[filename]")
|
|||||||
{
|
{
|
||||||
wxFileName fn1(wxT("/tmp/file1"));
|
wxFileName fn1(wxT("/tmp/file1"));
|
||||||
wxFileName fn2(wxT("/tmp/dir2/../file2"));
|
wxFileName fn2(wxT("/tmp/dir2/../file2"));
|
||||||
fn1.Normalize();
|
fn1.MakeAbsolute();
|
||||||
fn2.Normalize();
|
fn2.MakeAbsolute();
|
||||||
CHECK(fn1.GetPath() == fn2.GetPath());
|
CHECK(fn1.GetPath() == fn2.GetPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user