#include </home/zeitlin/src/wx/github/interface/wx/filesys.h>
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 (see wxFileSystemHandler) to provide access to user-defined virtual file systems.
Public Member Functions | |
wxFileSystem () | |
Constructor. | |
void | ChangePathTo (const wxString &location, bool is_dir=false) |
Sets the current location. | |
bool | FindFileInPath (wxString *pStr, const wxString &path, const wxString &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. | |
wxString | FindFirst (const wxString &wildcard, int flags=0) |
Works like wxFindFirstFile(). | |
wxString | FindNext () |
Returns the next filename that matches the parameters passed to FindFirst(). | |
wxString | GetPath () const |
Returns the actual path (set by wxFileSystem::ChangePathTo). | |
wxFSFile * | OpenFile (const wxString &location, int flags=wxFS_READ) |
Opens the file and returns a pointer to a wxFSFile object or NULL if failed. | |
Static Public Member Functions | |
static void | AddHandler (wxFileSystemHandler *handler) |
This static function adds new handler into the list of handlers (see wxFileSystemHandler) which provide access to virtual FS. | |
static wxFileSystemHandler * | RemoveHandler (wxFileSystemHandler *handler) |
Remove a filesystem handler from the list of handlers. | |
static wxString | FileNameToURL (const wxFileName &filename) |
Converts a wxFileName into an URL. | |
static bool | HasHandlerForPath (const wxString &location) |
This static function returns true if there is a registered handler which can open the given location. | |
static wxFileName | URLToFileName (const wxString &url) |
Converts URL into a well-formed filename. |
wxFileSystem::wxFileSystem | ( | ) |
Constructor.
The initial current path of this object will be empty (i.e. GetPath() == wxEmptyString) which means that e.g. OpenFile() or FindFirst() functions will use current working directory as current path (see also wxGetCwd).
static void wxFileSystem::AddHandler | ( | wxFileSystemHandler * | handler | ) | [static] |
This static function adds new handler into the list of handlers (see wxFileSystemHandler) which provide access to virtual FS.
Note that if two handlers for the same protocol are added, the last added one takes precedence.
wxFileSystem::AddHandler(new My_FS_Handler);
void wxFileSystem::ChangePathTo | ( | const wxString & | location, |
bool | is_dir = false |
||
) |
Sets the current location.
location parameter passed to OpenFile() is relative to this path.
All these commands change the path to "dir/subdir/":
ChangePathTo("dir/subdir/xh.htm"); ChangePathTo("dir/subdir", true); ChangePathTo("dir/subdir/", true);
例:
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' !!
location | the new location. Its meaning depends on the value of is_dir |
is_dir | if true location is new directory. If false (the default) location is file in the new directory. |
static wxString wxFileSystem::FileNameToURL | ( | const wxFileName & | filename | ) | [static] |
Converts a wxFileName into an URL.
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.
pStr | Receives the full path of the file, must not be NULL |
path | wxPATH_SEP-separated list of directories |
file | the name of the file to look for |
Works like wxFindFirstFile().
Returns the name of the first filename (within filesystem's current path) that matches wildcard.
wildcard | The wildcard that the filename must match |
flags | One of wxFILE (only files), wxDIR (only directories) or 0 (both). |
wxString wxFileSystem::FindNext | ( | ) |
Returns the next filename that matches the parameters passed to FindFirst().
wxString wxFileSystem::GetPath | ( | ) | const |
Returns the actual path (set by wxFileSystem::ChangePathTo).
static bool wxFileSystem::HasHandlerForPath | ( | const wxString & | location | ) | [static] |
This static function returns true if there is a registered handler which can open the given 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. flags can be one or more of the wxFileSystemOpenFlags values combined together.
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.
static wxFileSystemHandler* wxFileSystem::RemoveHandler | ( | wxFileSystemHandler * | handler | ) | [static] |
Remove a filesystem handler from the list of handlers.
static wxFileName wxFileSystem::URLToFileName | ( | const wxString & | url | ) | [static] |
Converts URL into a well-formed filename.
The URL must use the file
protocol.