Version: 3.0.2
wxFSFile Class Reference

#include <wx/filesys.h>

+ Inheritance diagram for wxFSFile:

Detailed Description

This class represents a single file opened by wxFileSystem.

It provides more information than wxWidgets' input streams (stream, filename, mime type, anchor).

Any pointer returned by a method of wxFSFile is valid only as long as the wxFSFile object exists. For example a call to GetStream() doesn't create the stream but only returns the pointer to it. In other words after 10 calls to GetStream() you will have obtained ten identical pointers.

Library:  wxBase
Category:  Virtual File System, File Handling
See Also
wxFileSystemHandler, wxFileSystem, wxFileSystem Overview

Public Member Functions

 wxFSFile (wxInputStream *stream, const wxString &location, const wxString &mimetype, const wxString &anchor, wxDateTime modif)
wxInputStreamDetachStream ()
 Detaches the stream from the wxFSFile object.
const wxStringGetAnchor () const
 Returns anchor (if present).
const wxStringGetLocation () const
 Returns full location of the file, including path and protocol.
const wxStringGetMimeType () const
 Returns the MIME type of the content of this file.
wxDateTime GetModificationTime () const
 Returns time when this file was modified.
wxInputStreamGetStream () const
 Returns pointer to the stream.
- Public Member Functions inherited from wxObject
 wxObject ()
 Default ctor; initializes to NULL the internal reference data.
 wxObject (const wxObject &other)
 Copy ctor.
virtual ~wxObject ()
virtual wxClassInfoGetClassInfo () const
 This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar).
wxObjectRefDataGetRefData () const
 Returns the wxObject::m_refData pointer, i.e. the data referenced by this object.
bool IsKindOf (const wxClassInfo *info) const
 Determines whether this class is a subclass of (or the same class as) the given class.
bool IsSameAs (const wxObject &obj) const
 Returns true if this object has the same data pointer as obj.
void Ref (const wxObject &clone)
 Makes this object refer to the data in clone.
void SetRefData (wxObjectRefData *data)
 Sets the wxObject::m_refData pointer.
void UnRef ()
 Decrements the reference count in the associated data, and if it is zero, deletes the data.
void UnShare ()
 This is the same of AllocExclusive() but this method is public.
void operator delete (void *buf)
 The delete operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined.
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.

Additional Inherited Members

- Protected Member Functions inherited from wxObject
void AllocExclusive ()
 Ensure that this object's data is not shared with any other object.
virtual wxObjectRefDataCreateRefData () const
 Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it.
virtual wxObjectRefDataCloneRefData (const wxObjectRefData *data) const
 Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data.
- Protected Attributes inherited from wxObject
 Pointer to an object which is the object's reference-counted data.

Constructor & Destructor Documentation

wxFSFile::wxFSFile ( wxInputStream stream,
const wxString location,
const wxString mimetype,
const wxString anchor,
wxDateTime  modif 


You probably won't use it. See the Note for details.

It is seldom used by the application programmer but you will need it if you are writing your own virtual FS. For example you may need something similar to wxMemoryInputStream, but because wxMemoryInputStream doesn't free the memory when destroyed and thus passing a memory stream pointer into wxFSFile constructor would lead to memory leaks, you can write your own class derived from wxFSFile:

class wxMyFSFile : public wxFSFile
void *m_Mem;
~wxMyFSFile() {free(m_Mem);}
// of course dtor is virtual ;-)

If you are not sure of the meaning of these params, see the description of the GetXXXX() functions.

streamThe input stream that will be used to access data
locationThe full location (aka filename) of the file
mimetypeMIME type of this file. It may be left empty, in which case the type will be determined from file's extension (location must not be empty in this case).
anchorAnchor. See GetAnchor() for details.
modifModification date and time for this file.

Member Function Documentation

wxInputStream* wxFSFile::DetachStream ( )

Detaches the stream from the wxFSFile object.

That is, the stream obtained with GetStream() will continue its existence after the wxFSFile object is deleted.

You will have to delete the stream yourself.

const wxString& wxFSFile::GetAnchor ( ) const

Returns anchor (if present).

The term of anchor can be easily explained using few examples:

index.htm#anchor                      // 'anchor' is anchor
index/wx001.htm                       // NO anchor here!
archive/ // 'global'
archive/        // NO anchor here!

Usually an anchor is presented only if the MIME type is 'text/html'. But it may have some meaning with other files; for example myanim.avi#200 may refer to position in animation or reality.wrl::MyView may refer to a predefined view in VRML.

const wxString& wxFSFile::GetLocation ( ) const

Returns full location of the file, including path and protocol.

const wxString& wxFSFile::GetMimeType ( ) const

Returns the MIME type of the content of this file.

It is either extension-based (see wxMimeTypesManager) or extracted from HTTP protocol Content-Type header.

wxDateTime wxFSFile::GetModificationTime ( ) const

Returns time when this file was modified.

wxInputStream* wxFSFile::GetStream ( ) const

Returns pointer to the stream.

You can use the returned stream to directly access data. You may suppose that the stream provide Seek and GetSize functionality (even in the case of the HTTP protocol which doesn't provide this by default. wxHtml uses local cache to work around this and to speed up the connection).