git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18116
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
#include "wx/stream.h"
#include "wx/url.h"
#include "wx/datetime.h"
#include "wx/stream.h"
#include "wx/url.h"
#include "wx/datetime.h"
+#include "wx/filename.h"
class wxFSFile;
class wxFileSystemHandler;
class wxFSFile;
class wxFileSystemHandler;
static void CleanUpHandlers();
// Returns the native path for a file URL
static void CleanUpHandlers();
// Returns the native path for a file URL
- static wxString URLToNativePath( const wxString& url );
+ static wxFileName URLToFileName(const wxString& url);
// Returns the file URL for a native path
// Returns the file URL for a native path
- static wxString NativePathToURL( const wxString& path );
+ static wxString FileNameToURL(const wxFileName& filename);
{
// location has Unix path separators
wxString right = ms_root + GetRightLocation(location);
{
// location has Unix path separators
wxString right = ms_root + GetRightLocation(location);
- wxString nativePath = wxFileSystem::URLToNativePath(right);
- wxFileName fn(nativePath, wxPATH_UNIX);
+ wxFileName fn = wxFileSystem::URLToFileName(right);
if (!wxFileExists(fn.GetFullPath()))
return (wxFSFile*) NULL;
if (!wxFileExists(fn.GetFullPath()))
return (wxFSFile*) NULL;
wxString wxLocalFSHandler::FindFirst(const wxString& spec, int flags)
{
wxString right = ms_root + GetRightLocation(spec);
wxString wxLocalFSHandler::FindFirst(const wxString& spec, int flags)
{
wxString right = ms_root + GetRightLocation(spec);
- return wxFindFirstFile(right, flags);
+ return wxFindFirstFile(wxFileSystem::URLToFileName(right).GetFullPath(),
+ flags);
}
wxString wxLocalFSHandler::FindNext()
}
wxString wxLocalFSHandler::FindNext()
const static wxString g_nativePathString(wxFILE_SEP_PATH);
// Returns the native path for a file URL
const static wxString g_nativePathString(wxFILE_SEP_PATH);
// Returns the native path for a file URL
-wxString wxFileSystem::URLToNativePath( const wxString& url )
+wxFileName wxFileSystem::URLToFileName(const wxString& url)
if ( path.Find(wxT("file://")) == 0 )
{
if ( path.Find(wxT("file://")) == 0 )
{
// which only exists on msw and corresponds to a unc
if ( path[0u] == wxT('/') && path [1u] != wxT('/'))
{
// which only exists on msw and corresponds to a unc
if ( path[0u] == wxT('/') && path [1u] != wxT('/'))
{
}
else if ( (url.Find(wxT("file://")) == 0) &&
(path.Find(wxT('/')) != wxNOT_FOUND) &&
(path.Length() > 1) && (path[1u] != wxT(':')) )
{
}
else if ( (url.Find(wxT("file://")) == 0) &&
(path.Find(wxT('/')) != wxNOT_FOUND) &&
(path.Length() > 1) && (path[1u] != wxT(':')) )
{
- path = wxT("//") + path ;
+ path = wxT("//") + path;
- path.Replace(g_unixPathString, g_nativePathString) ;
+ path.Replace(g_unixPathString, g_nativePathString);
+ return wxFileName(path, wxPATH_NATIVE);
}
// Returns the file URL for a native path
}
// Returns the file URL for a native path
-wxString wxFileSystem::NativePathToURL( const wxString& path )
+wxString wxFileSystem::FileNameToURL(const wxFileName& filename)
+ wxFileName fn = filename;
+ fn.Normalize(wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_ABSOLUTE);
+ wxString url = fn.GetFullPath(wxPATH_NATIVE);
- // unc notation
- if ( url.Find(wxT("\\\\")) == 0 )
- {
- url = url.Mid(2) ;
- }
- else
+ // unc notation
+ if ( url.Find(wxT("\\\\")) == 0 )
+ {
+ url = url.Mid(2);
+ }
+ else
+ {
+ url = wxT("/") + url;
+ }
- {
- url = wxT("/") + url ;
- }
- url.Replace(g_nativePathString, g_unixPathString) ;
- url = wxT("file://") + url ;
- return url ;
+ url.Replace(g_nativePathString, g_unixPathString);
+ url = wxT("file://") + url;
+ return url;
if (right.GetChar(0) == wxT('/')) right = right.Mid(1);
if (right.GetChar(0) == wxT('/')) right = right.Mid(1);
- wxString leftFilename = wxFileSystem::URLToNativePath(left);
+ wxFileName leftFilename = wxFileSystem::URLToFileName(left);
- s = new wxZipInputStream(leftFilename, right);
+ s = new wxZipInputStream(leftFilename.GetFullPath(), right);
if (s && s->IsOk() )
{
return new wxFSFile(s,
if (s && s->IsOk() )
{
return new wxFSFile(s,
- m_Archive = (void*) unzOpen(m_ZipFile.mb_str());
+ wxString nativename = wxFileSystem::URLToFileName(m_ZipFile).GetFullPath();
+ m_Archive = (void*) unzOpen(nativename.mb_str());
m_Pattern = right.AfterLast(wxT('/'));
m_BaseDir = right.BeforeLast(wxT('/'));
m_Pattern = right.AfterLast(wxT('/'));
m_BaseDir = right.BeforeLast(wxT('/'));