]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/fs.tex
added wxHtmlHelpController::AddBook(wxFileName)
[wxWidgets.git] / docs / latex / wx / fs.tex
... / ...
CommitLineData
1\section{wxFileSystem}\label{fs}
2
3The wxHTML library uses a {\bf virtual file systems} mechanism
4similar to the one used in Midnight Commander, Dos Navigator,
5FAR or almost any modern file manager. It allows the user to access
6data stored in archives as if they were ordinary files. On-the-fly
7generated files that exist only in memory are also supported.
8
9\wxheading{Classes}
10
11Three classes are used in order to provide virtual file systems mechanism:
12
13\begin{itemize}\itemsep=0pt
14\item The \helpref{wxFSFile}{wxfsfile} class provides information
15about opened file (name, input stream, mime type and anchor).
16\item The \helpref{wxFileSystem}{wxfilesystem} class is the interface.
17Its main methods are ChangePathTo() and OpenFile(). This class
18is most often used by the end user.
19\item The \helpref{wxFileSystemHandler}{wxfilesystemhandler} is the core
20of virtual file systems mechanism. You can derive your own handler and pass it to
21of the VFS mechanism. You can derive your own handler and pass it to
22wxFileSystem's AddHandler() method. In the new handler you only need to
23override the OpenFile() and CanOpen() methods.
24\end{itemize}
25
26\wxheading{Locations}
27
28Locations (aka filenames aka addresses) are constructed from four parts:
29
30\begin{itemize}\itemsep=0pt
31\item {\bf protocol} - handler can recognize if it is able to open a
32file by checking its protocol. Examples are "http", "file" or "ftp".
33\item {\bf right location} - is the name of file within the protocol.
34In "http://www.wxwindows.org/index.html" the right location is "//www.wxwindows.org/index.html".
35\item {\bf anchor} - an anchor is optional and is usually not present.
36In "index.htm\#chapter2" the anchor is "chapter2".
37\item {\bf left location} - this is usually an empty string.
38It is used by 'local' protocols such as ZIP.
39See Combined Protocols paragraph for details.
40\end{itemize}
41
42\wxheading{Combined Protocols}
43
44The left location precedes the protocol in the URL string.
45It is not used by global protocols like HTTP but it becomes handy when nesting
46protocols - for example you may want to access files in a ZIP archive:
47
48file:archives/cpp\_doc.zip\#zip:reference/fopen.htm\#syntax
49
50In this example, the protocol is "zip", the left location is
51"reference/fopen.htm", the anchor is "syntax" and the right location
52is "file:archives/cpp\_doc.zip".
53
54There are {\bf two} protocols used in this example: "zip" and "file".
55
56\wxheading{File Systems Included in wxHTML}
57
58The following virtual file system handlers are part of wxWindows so far:
59
60\begin{twocollist}
61\twocolitem{{\bf wxInternetFSHandler}}{A handler for accessing documents
62via HTTP or FTP protocols. Include file is <wx/fs\_inet.h>.}
63\twocolitem{{\bf wxZipFSHandler}}{A handler for ZIP archives.
64Include file is <wx/fs\_zip.h>. URL is in form "archive.zip\#zip:filename".}
65\twocolitem{{\bf wxMemoryFSHandler}}{This handler allows you to access
66data stored in memory (such as bitmaps) as if they were regular files.
67See \helpref{wxMemoryFSHandler documentation}{wxmemoryfshandler} for details.
68Include file is <wx/fs\_mem.h>. URL is prefixed with memory:, e.g.
69"memory:myfile.htm"}
70\end{twocollist}
71
72In addition, wxFileSystem itself can access local files.
73
74
75\wxheading{Initializing file system handlers}
76
77Use \helpref{wxFileSystem::AddHandler}{wxfilesystemaddhandler} to initialize
78a handler, for example:
79
80\begin{verbatim}
81#include <wx/fs_mem.h>
82
83...
84
85bool MyApp::OnInit()
86{
87 wxFileSystem::AddHandler(new wxMemoryFSHandler);
88...
89}
90\end{verbatim}
91