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



wxFileSystem::wxFileSystem



wxFileSystem(void)

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);
  ChangePathTo("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(void)

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(void)

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. Note that the user is responsible for deleting the returned wxFSFile.



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

ymasuda 平成17年11月19日