Classes derived from FileSystemHandler are used to access virtual file systems.
Its public interface consists of two methods: FileSystemHandler.CanOpen and FileSystemHandler.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 (see FileSystem) if you don’t know how locations are constructed.
Also consult the list of available handlers.
Note that the handlers are shared by all instances of FileSystem.
Note
HTML library provides handlers for local files and HTTP or FTP protocol.
Note
The location parameter passed to OpenFile or CanOpen methods is always an absolute path. You don’t need to check the FS’s current path.
See also
__init__ | Constructor. |
CanOpen | Returns True if the handler is able to open this file. |
FindFirst | Works like FindFirstFile. |
FindNext | Returns next filename that matches parameters passed to FileSystem.FindFirst . |
GetMimeTypeFromExt | Returns the MIME type based on extension of location. |
OpenFile | Opens the file and returns FSFile pointer or None if failed. |
Classes derived from FileSystemHandler are used to access virtual file systems.
Possible constructors:
FileSystemHandler()
Constructor.
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:
def CanOpen(self, location):
return self.GetProtocol(location) == "http"
Must be overridden in derived handlers.
Parameters: | location (string) – |
---|---|
Return type: | bool |
Works like FindFirstFile.
Returns the name of the first filename (within filesystem’s current path) that matches wildcard. flags may be one of FILE (only files), DIR (only directories) or 0 (both).
This method is only called if CanOpen returns True.
Parameters: |
|
---|---|
Return type: | string |
Returns next filename that matches parameters passed to FileSystem.FindFirst .
This method is only called if CanOpen returns True and FindFirst returned a non-empty string.
Return type: | string |
---|
Returns the MIME type based on extension of location.
(While FSFile.GetMimeType returns real MIME type - either extension-based or queried from HTTP.)
Example:
if GetMimeTypeFromExt("index.htm") == "text/html":
wx.MessageBox("Is HTML!")
Parameters: | location (string) – |
---|---|
Return type: | string |
Opens the file and returns FSFile pointer or None if failed.
Must be overridden in derived handlers.
Parameters: |
|
---|---|
Return type: |