wx.FileSystem

Inheritance diagram for wx.FileSystem:



Description

This class provides an interface for opening files on different file systems. It can handle absolute and/or local filenames. It uses a system of handlers to provide access to user-defined virtual file systems.

Derived From

Properties Summary

Class API

Methods

__init__()
No docstrings available for this method.

AddHandler(handler)

This static function adds new handler into the list of handlers which provide access to virtual FS. Note that if two handlers for the same protocol are added, the last one added takes precedence.

Parameters:


ChangePathTo(location, is_dir=False)

Sets the current location. location parameter passed to OpenFile is relative to this path.

Parameters:

  • location (string): the new location. Its meaning depends on the value of is_dir
  • is_dir (bool): if True location is new directory. If False (default) location is file in the new directory.

Warning

Unless is_dir is True the location parameter is not the directory name but the name of the file in this directory. All these commands change the path to “dir/subdir/”:

ChangePathTo("dir/subdir/xh.htm")
ChangePathTo("dir/subdir", True)
ChangePathTo("dir/subdir/", True)

CleanUpHandlers()
No docstrings available for this method.

FileNameToURL(filename)

Converts filename into URL.

Parameters:

  • filename (string)

Returns:

string

See also

URLToFileName


FindFirst(wildcard, flags=0)

Returns name of the first filename (within filesystem’s current path) that matches wildcard. flags may be one of wx.FILE (only files), wx.DIR (only directories) or 0 (both).

Parameters:

  • wildcard (string)
  • flags (int)

Returns:

string


FindNext()

Returns the next filename that matches parameters passed to FindFirst.


Returns:

string


GetPath()

Returns actual path (set by ChangePathTo).


Returns:

string


OpenFile(location)

Opens the file and returns a pointer to a wx.FSFile object or None if failed. It first tries to open the file in relative scope (based on value passed to ChangePathTo() method) and then as an absolute path.

A stream opened with just the default wx.FS_READ flag may or may not be seekable depending on the underlying source. Passing wx.FS_READ | wx.FS_SEEKABLE for flags will back a stream that is not natively seekable with memory or a file and return a stream that is always seekable.

Parameters:

  • location (string)

Returns:

wx.FSFile

Note

Note that the user is responsible for deleting the returned wx.FSFile.


RemoveHandler(handler)

Parameters:

  • handler (wx.CPPFileSystemHandler)

Returns:

wx.CPPFileSystemHandler


URLToFileName(url)

Converts URL into a well-formed filename. The URL must use the file protocol.

Parameters:

  • url (string)

Returns:

string


Properties

Path
See GetPath