wxfilesystemthis 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 include files <wx/filesys.h> see also wxfilesystemhandler, wxfsfile, overview members
wxfilesystem::wxfilesystem
wxfilesystem::wxfilesystemwxfilesystem() constructor.
wxfilesystem::addhandlerstatic void addhandler(wxfilesystemhandler *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. note you can call:
wxfilesystem::addhandler(new my_fs_handler);this is because (a) addhandler is a static method, and (b) the handlers are deleted in wxfilesystem's destructor so that you don't have to care about it.
wxfilesystem::hashandlerforpathstatic bool hashandlerforpath(const wxstring & location) this static function returns true if there is a registered handler which can open the given location.
wxfilesystem::changepathtovoid changepathto(const wxstring& location, bool is_dir = false) sets the current location. location parameter passed to openfile is relative to this path. caution! 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);parameters location
is_dir
example
f = fs -> openfile("hello.htm"); // opens file 'hello.htm' fs -> changepathto("subdir/folder", true); f = fs -> openfile("hello.htm"); // opens file 'subdir/folder/hello.htm' !! wxfilesystem::getpathwxstring getpath() returns actual path (set by changepathto).
wxfilesystem::filenametourlstatic wxstring filenametourl(wxfilename filename) converts filename into url. see also wxfilesystem::urltofilename, wxfilename
wxfilesystem::findfileinpathbool findfileinpath(wxstring *str, const wxchar *path, const wxchar *file) looks for the file with the given name file in a colon or semi-colon (depending on the current platform) separated list of directories in path. if the file is found in any directory, returns true and the full path of the file in str, otherwise returns false and doesn't modify str. parameters str
path
file
wxfilesystem::findfirstwxstring 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).
wxfilesystem::findnextwxstring findnext() returns the next filename that matches parameters passed to findfirst.
wxfilesystem::openfilewxfsfile* openfile(const wxstring& location, int flags = wxfs_read) opens the file and returns a pointer to a wxfsfile object or null 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. note that the user is responsible for deleting the returned wxfsfile. flags can be one or more of the following bit values ored together:
// open bit flags enum { wxfs_read = 1, // open for reading wxfs_seekable = 4 // returned stream will be seekable };a stream opened with just the default wxfs_read flag may or may not be seekable depending on the underlying source. passing wxfs_read | wxfs_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.
wxfilesystem::urltofilenamestatic wxfilename urltofilename(const wxstring& url) converts url into a well-formed filename. the url must use the file protocol. see also wxfilesystem::filenametourl, wxfilename
|