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:
parent
1f2413c461
commit
6d2af9e7a1
4 changed files with 15 additions and 15 deletions
|
|
@ -361,7 +361,7 @@ public:
|
|||
bool MakeRelativeTo(const wxString& pathBase = wxEmptyString,
|
||||
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
|
||||
bool MakeAbsolute(const wxString& cwd = wxEmptyString,
|
||||
|
|
|
|||
|
|
@ -575,15 +575,15 @@ MyFrame::MyFrame()
|
|||
m_fileHistory->UseMenu(m_fileHistoryMenu);
|
||||
|
||||
wxFileName fn( "menu.cpp" );
|
||||
fn.Normalize();
|
||||
fn.MakeAbsolute();
|
||||
m_fileHistory->AddFileToHistory( fn.GetFullPath() );
|
||||
|
||||
fn = "Makefile.in";
|
||||
fn.Normalize();
|
||||
fn.MakeAbsolute();
|
||||
m_fileHistory->AddFileToHistory( fn.GetFullPath() );
|
||||
|
||||
fn.Assign("minimal", "minimal", "cpp");
|
||||
fn.Normalize();
|
||||
fn.MakeAbsolute();
|
||||
m_fileHistory->AddFileToHistory( fn.GetFullPath() );
|
||||
|
||||
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
|
||||
wxString cwd = wxGetCwd();
|
||||
|
||||
// Normalize both paths to be absolute but avoid expanding environment
|
||||
// variables in them, this could be unexpected.
|
||||
const int normFlags = wxPATH_NORM_DOTS |
|
||||
wxPATH_NORM_TILDE |
|
||||
wxPATH_NORM_ABSOLUTE |
|
||||
wxPATH_NORM_LONG;
|
||||
Normalize(normFlags, cwd, format);
|
||||
fnBase.Normalize(normFlags, cwd, format);
|
||||
// Bring both paths to canonical form.
|
||||
MakeAbsolute(cwd, format);
|
||||
fnBase.MakeAbsolute(cwd, format);
|
||||
|
||||
// Do this here for compatibility, as we used to do it before.
|
||||
Normalize(wxPATH_NORM_LONG, cwd, format);
|
||||
fnBase.Normalize(wxPATH_NORM_LONG, cwd, format);
|
||||
|
||||
|
||||
bool withCase = IsCaseSensitive(format);
|
||||
|
||||
|
|
@ -2620,7 +2620,7 @@ static wxString EscapeFileNameCharsInURL(const char *in)
|
|||
wxString wxFileName::FileNameToURL(const wxFileName& filename)
|
||||
{
|
||||
wxFileName fn = filename;
|
||||
fn.Normalize(wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_ABSOLUTE);
|
||||
fn.MakeAbsolute();
|
||||
wxString url = fn.GetFullPath(wxPATH_NATIVE);
|
||||
|
||||
#ifndef __UNIX__
|
||||
|
|
|
|||
|
|
@ -201,8 +201,8 @@ TEST_CASE("wxFileName::Comparison", "[filename]")
|
|||
{
|
||||
wxFileName fn1(wxT("/tmp/file1"));
|
||||
wxFileName fn2(wxT("/tmp/dir2/../file2"));
|
||||
fn1.Normalize();
|
||||
fn2.Normalize();
|
||||
fn1.MakeAbsolute();
|
||||
fn2.MakeAbsolute();
|
||||
CHECK(fn1.GetPath() == fn2.GetPath());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue