Slightly simplify wxFileName::URLToFileName()
Use wxString::StartsWith() instead of comparing the result of Find() with 0: this is shorter and more clear (and marginally more efficient). No real changes.
This commit is contained in:
@@ -2505,15 +2505,12 @@ bool wxFileName::SetPermissions(int permissions)
|
|||||||
// Returns the native path for a file URL
|
// Returns the native path for a file URL
|
||||||
wxFileName wxFileName::URLToFileName(const wxString& url)
|
wxFileName wxFileName::URLToFileName(const wxString& url)
|
||||||
{
|
{
|
||||||
wxString path = url;
|
wxString path;
|
||||||
|
if ( !url.StartsWith(wxS("file://"), &path) &&
|
||||||
if ( path.Find(wxT("file://")) == 0 )
|
!url.StartsWith(wxS("file:"), &path) )
|
||||||
{
|
{
|
||||||
path = path.Mid(7);
|
// Consider it's just the path without any schema.
|
||||||
}
|
path = url;
|
||||||
else if ( path.Find(wxT("file:")) == 0 )
|
|
||||||
{
|
|
||||||
path = path.Mid(5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
path = wxURI::Unescape(path);
|
path = wxURI::Unescape(path);
|
||||||
@@ -2526,7 +2523,7 @@ wxFileName wxFileName::URLToFileName(const wxString& url)
|
|||||||
{
|
{
|
||||||
path = path.Mid(1);
|
path = path.Mid(1);
|
||||||
}
|
}
|
||||||
else if ( (url.Find(wxT("file://")) == 0) &&
|
else if ( url.StartsWith(wxS("file://")) &&
|
||||||
(path.Find(wxT('/')) != wxNOT_FOUND) &&
|
(path.Find(wxT('/')) != wxNOT_FOUND) &&
|
||||||
(path.length() > 1) && (path[1u] != wxT(':')) )
|
(path.length() > 1) && (path[1u] != wxT(':')) )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user