Contents Up Previous Next

wxFileSystemHandler

Classes derived from wxFileSystemHandler are used to access virtual file systems. Its public interface consists of two methods: CanOpen and OpenFile. It provides additional protected methods to simplify the process of opening the file: GetProtocol, GetLeftLocation, GetRightLocation, GetAnchor, GetMimeTypeFromExt.

Please have a look at overview if you don't know how locations are constructed.

Also consult list of available handlers.

Notes

Derived from

wxObject

Include files

<wx/filesys.h>

See also

wxFileSystem, wxFSFile, Overview

Members

wxFileSystemHandler::wxFileSystemHandler
wxFileSystemHandler::CanOpen
wxFileSystemHandler::GetAnchor
wxFileSystemHandler::GetLeftLocation
wxFileSystemHandler::GetMimeTypeFromExt
wxFileSystemHandler::GetProtocol
wxFileSystemHandler::GetRightLocation
wxFileSystemHandler::FindFirst
wxFileSystemHandler::FindNext
wxFileSystemHandler::OpenFile


wxFileSystemHandler::wxFileSystemHandler

wxFileSystemHandler()

Constructor.


wxFileSystemHandler::CanOpen

virtual bool CanOpen(const wxString& location)

Returns true if the handler is able to open this file. This function doesn't check whether the file exists or not, it only checks if it knows the protocol. Example:

bool MyHand::CanOpen(const wxString& location) 
{
    return (GetProtocol(location) == "http");
}
Must be overridden in derived handlers.


wxFileSystemHandler::GetAnchor

wxString GetAnchor(const wxString& location) const

Returns the anchor if present in the location. See wxFSFile for details.

Example: GetAnchor("index.htm#chapter2") == "chapter2"

Note: the anchor is NOT part of the left location.


wxFileSystemHandler::GetLeftLocation

wxString GetLeftLocation(const wxString& location) const

Returns the left location string extracted from location.

Example: GetLeftLocation("file:myzipfile.zip#zip:index.htm") == "file:myzipfile.zip"


wxFileSystemHandler::GetMimeTypeFromExt

wxString GetMimeTypeFromExt(const wxString& location)

Returns the MIME type based on extension of location. (While wxFSFile::GetMimeType returns real MIME type - either extension-based or queried from HTTP.)

Example : GetMimeTypeFromExt("index.htm") == "text/html"


wxFileSystemHandler::GetProtocol

wxString GetProtocol(const wxString& location) const

Returns the protocol string extracted from location.

Example: GetProtocol("file:myzipfile.zip#zip:index.htm") == "zip"


wxFileSystemHandler::GetRightLocation

wxString GetRightLocation(const wxString& location) const

Returns the right location string extracted from location.

Example : GetRightLocation("file:myzipfile.zip#zip:index.htm") == "index.htm"


wxFileSystemHandler::FindFirst

virtual wxString FindFirst(const wxString& wildcard, int flags = 0)

Works like wxFindFirstFile. Returns name of the first filename (within filesystem's current path) that matches wildcard. flags may be one of wxFILE (only files), wxDIR (only directories) or 0 (both).

This method is only called if CanOpen returns true.


wxFileSystemHandler::FindNext

virtual wxString FindNext()

Returns next filename that matches parameters passed to FindFirst.

This method is only called if CanOpen returns true and FindFirst returned a non-empty string.


wxFileSystemHandler::OpenFile

virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location)

Opens the file and returns wxFSFile pointer or NULL if failed.

Must be overridden in derived handlers.

Parameters

fs

location