#include <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. More... | |
void | ChangePathTo (const wxString &location, bool is_dir=false) |
Sets the current location. More... | |
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. More... | |
wxString | FindFirst (const wxString &wildcard, int flags=0) |
Works like wxFindFirstFile(). More... | |
wxString | FindNext () |
Returns the next filename that matches the parameters passed to FindFirst(). More... | |
wxString | GetPath () const |
Returns the actual path (set by wxFileSystem::ChangePathTo). More... | |
wxFSFile * | OpenFile (const wxString &location, int flags=wxFS_READ) |
Opens the file and returns a pointer to a wxFSFile object or NULL if failed. More... | |
Public Member Functions inherited from wxObject | |
wxObject () | |
Default ctor; initializes to NULL the internal reference data. More... | |
wxObject (const wxObject &other) | |
Copy ctor. More... | |
virtual | ~wxObject () |
Destructor. More... | |
virtual wxClassInfo * | GetClassInfo () const |
This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More... | |
wxObjectRefData * | GetRefData () const |
Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More... | |
bool | IsKindOf (const wxClassInfo *info) const |
Determines whether this class is a subclass of (or the same class as) the given class. More... | |
bool | IsSameAs (const wxObject &obj) const |
Returns true if this object has the same data pointer as obj. More... | |
void | Ref (const wxObject &clone) |
Makes this object refer to the data in clone. More... | |
void | SetRefData (wxObjectRefData *data) |
Sets the wxObject::m_refData pointer. More... | |
void | UnRef () |
Decrements the reference count in the associated data, and if it is zero, deletes the data. More... | |
void | UnShare () |
This is the same of AllocExclusive() but this method is public. More... | |
void | operator delete (void *buf) |
The delete operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined. More... | |
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0) |
The new operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined. More... | |
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. More... | |
static wxFileSystemHandler * | RemoveHandler (wxFileSystemHandler *handler) |
Remove a filesystem handler from the list of handlers. More... | |
static wxString | FileNameToURL (const wxFileName &filename) |
Converts a wxFileName into an URL. More... | |
static bool | HasHandlerForPath (const wxString &location) |
This static function returns true if there is a registered handler which can open the given location. More... | |
static wxFileName | URLToFileName (const wxString &url) |
Converts URL into a well-formed filename. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from wxObject | |
void | AllocExclusive () |
Ensure that this object's data is not shared with any other object. More... | |
virtual wxObjectRefData * | CreateRefData () const |
Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More... | |
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const |
Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More... | |
Protected Attributes inherited from wxObject | |
wxObjectRefData * | m_refData |
Pointer to an object which is the object's reference-counted data. More... | |
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 |
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.
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/":
Example:
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 |
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 |
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 |
Remove a filesystem handler from the list of handlers.
|
static |
Converts URL into a well-formed filename.
The URL must use the file
protocol.