## wxFileSystem

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

wxObject

Include files

<wx/filesys.h>

See Also

wxFileSystemHandler, wxFSFile, Overview

Members

wxFileSystem::wxFileSystem
wxFileSystem::AddHandler
wxFileSystem::ChangePathTo
wxFileSystem::GetPath
wxFileSystem::FileNameToURL
wxFileSystem::FindFirst
wxFileSystem::FindNext
wxFileSystem::OpenFile
wxFileSystem::URLToFileName

### wxFileSystem::wxFileSystem

wxFileSystem()

Constructor.

### wxFileSystem::AddHandler

static void AddHandler(wxFileSystemHandler *handler)

This static function adds new handler into the list of handlers. The handlers provide access to virtual FS.

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::ChangePathTo

void 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);
    C  hangePathTo("dir/subdir/", TRUE);

Parameters

location

the new location. Its meaning depends on the value of is_dir

is_dir

if TRUE location is new directory. If FALSE (default) location is file in the new directory.

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::GetPath

wxString GetPath()

Returns actual path (set by ChangePathTo).

### wxFileSystem::FileNameToURL

static wxString FileNameToURL(wxFileName filename)

Converts filename into URL.

See also

wxFileSystem::URLToFileName, wxFileName

### wxFileSystem::FindFirst

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).

### wxFileSystem::FindNext

wxString FindNext()

Returns the next filename that matches parameters passed to FindFirst.

### wxFileSystem::OpenFile

wxFSFile* OpenFile(const wxString& location)

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.

### wxFileSystem::URLToFileName

static wxFileName URLToFileName(const wxString&url)

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

See also

wxFileSystem::FileNameToURL, wxFileName