## 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::FindFirst
wxFileSystem::FindNext
wxFileSystem::OpenFile

### 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 directory name but the name of the file in this directory!! All these commands change path to "dir/subdir/" :

    ChangePathTo("dir/subdir/xh.htm");
    ChangePathTo("dir/subdir", TRUE);
    ChangePathTo("dir/subdir/", TRUE);

Parameters

location

the new location. Its meaning depends on 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::FindFirst

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

Works like wxFindFirstFile. Returns name of the first filename (withing 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 next filename that matches parameters passed to FindFirst.

### wxFileSystem::OpenFile

wxFSFile* OpenFile(const wxString& location)

Opens file and returns pointer to 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.