#include </home/zeitlin/src/wx/github/interface/wx/filesys.h>
This class represents a single file opened by wxFileSystem.
It provides more informations than wxWidgets' input streams (stream, filename, mime type, anchor).
Public Member Functions | |
wxFSFile (wxInputStream *stream, const wxString &location, const wxString &mimetype, const wxString &anchor, wxDateTime modif) | |
Constructor. | |
wxInputStream * | DetachStream () |
Detaches the stream from the wxFSFile object. | |
const wxString & | GetAnchor () const |
Returns anchor (if present). | |
const wxString & | GetLocation () const |
Returns full location of the file, including path and protocol. | |
const wxString & | GetMimeType () const |
Returns the MIME type of the content of this file. | |
wxDateTime | GetModificationTime () const |
Returns time when this file was modified. | |
wxInputStream * | GetStream () const |
Returns pointer to the stream. |
wxFSFile::wxFSFile | ( | wxInputStream * | stream, |
const wxString & | location, | ||
const wxString & | mimetype, | ||
const wxString & | anchor, | ||
wxDateTime | modif | ||
) |
Constructor.
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 { private: void *m_Mem; public: wxMyFSFile(.....) ~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.
stream | The input stream that will be used to access data |
location | The full location (aka filename) of the file |
mimetype | MIME 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). |
anchor | Anchor. See GetAnchor() for details. |
modif | Modification date and time for this file. |
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/main.zip#zip:index.htm#global // 'global' archive/main.zip#zip:index.htm // 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.
Examples:
http://www.wxwidgets.org http://www.ms.mff.cuni.cz/~vsla8348/wxhtml/archive.zip#zip:info.txt file:/home/vasek/index.htm relative-file.htm
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).