From b8b37cedd39bae3a3653003a7f8ae5fecf4df78f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 24 Jul 2006 17:37:39 +0000 Subject: [PATCH] added HasHandlerForPath() (modified patch 1514524) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40281 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/filesys.tex | 8 ++++++++ include/wx/filesys.h | 3 +++ src/common/filesys.cpp | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/docs/latex/wx/filesys.tex b/docs/latex/wx/filesys.tex index 15bfcca767..5f28f6f092 100644 --- a/docs/latex/wx/filesys.tex +++ b/docs/latex/wx/filesys.tex @@ -54,6 +54,14 @@ are deleted in wxFileSystem's destructor so that you don't have to care about it. +\membersection{wxFileSystem::HasHandlerForPath}\label{wxfilesystemhashandlerforpath} + +\func{static bool}{HasHandlerForPath}{\param{const wxString \&}{ location}} + +This static function returns \true if there is a registered handler which can open the given +location. + + \membersection{wxFileSystem::ChangePathTo}\label{wxfilesystemchangepathto} \func{void}{ChangePathTo}{\param{const wxString\& }{location}, \param{bool }{is\_dir = false}} diff --git a/include/wx/filesys.h b/include/wx/filesys.h index ff06ee7dbd..354d940275 100644 --- a/include/wx/filesys.h +++ b/include/wx/filesys.h @@ -188,6 +188,9 @@ public: // In fact, this class is only front-end to the FS handlers :-) static void AddHandler(wxFileSystemHandler *handler); + // Returns true if there is a handler which can open the given location. + static bool HasHandlerForPath(const wxString& location); + // remove all items from the m_Handlers list static void CleanUpHandlers(); diff --git a/src/common/filesys.cpp b/src/common/filesys.cpp index 61ec083da4..5e99f9787a 100644 --- a/src/common/filesys.cpp +++ b/src/common/filesys.cpp @@ -485,6 +485,18 @@ void wxFileSystem::AddHandler(wxFileSystemHandler *handler) m_Handlers.Append(handler); } +bool wxFileSystem::HasHandlerForPath(const wxString &location) +{ + for ( wxList::compatibility_iterator node = m_Handlers.GetFirst(); + node; node = node->GetNext() ) + { + wxFileSystemHandler *h = (wxFileSystemHandler*) node->GetData(); + if (h->CanOpen(location)) + return true; + } + + return false; +} void wxFileSystem::CleanUpHandlers() { -- 2.45.2