]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/fs.tex
replaced deprecated wxMULTIPLE with wxFD_MULTIPLE
[wxWidgets.git] / docs / latex / wx / fs.tex
CommitLineData
ccaaf5b0 1\section{wxFileSystem}\label{fs}
704a4b75 2
b453e1b2
RR
3The wxHTML library uses a {\bf virtual file systems} mechanism
4similar to the one used in Midnight Commander, Dos Navigator,
f6bcfd97
BP
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.
704a4b75
VS
8
9\wxheading{Classes}
10
f6bcfd97 11Three classes are used in order to provide virtual file systems mechanism:
704a4b75 12
22d6efa8 13\begin{itemize}\itemsep=0pt
b453e1b2 14\item The \helpref{wxFSFile}{wxfsfile} class provides information
f6bcfd97 15about opened file (name, input stream, mime type and anchor).
b453e1b2
RR
16\item The \helpref{wxFileSystem}{wxfilesystem} class is the interface.
17Its main methods are ChangePathTo() and OpenFile(). This class
704a4b75 18is most often used by the end user.
b453e1b2 19\item The \helpref{wxFileSystemHandler}{wxfilesystemhandler} is the core
f6bcfd97 20of virtual file systems mechanism. You can derive your own handler and pass it to
aea22172 21the VFS mechanism. You can derive your own handler and pass it to
704a4b75 22wxFileSystem's AddHandler() method. In the new handler you only need to
f6bcfd97 23override the OpenFile() and CanOpen() methods.
704a4b75
VS
24\end{itemize}
25
26\wxheading{Locations}
27
f6bcfd97 28Locations (aka filenames aka addresses) are constructed from four parts:
704a4b75 29
22d6efa8 30\begin{itemize}\itemsep=0pt
b453e1b2
RR
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".
704a4b75 33\item {\bf right location} - is the name of file within the protocol.
fc2171bd 34In "http://www.wxwidgets.org/index.html" the right location is "//www.wxwidgets.org/index.html".
f6bcfd97 35\item {\bf anchor} - an anchor is optional and is usually not present.
b453e1b2 36In "index.htm\#chapter2" the anchor is "chapter2".
b453e1b2 37\item {\bf left location} - this is usually an empty string.
704a4b75
VS
38It is used by 'local' protocols such as ZIP.
39See Combined Protocols paragraph for details.
40\end{itemize}
41
42\wxheading{Combined Protocols}
43
f6bcfd97
BP
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
7e139aaf 46protocols - for example you may want to access files in a ZIP archive:
704a4b75
VS
47
48file:archives/cpp\_doc.zip\#zip:reference/fopen.htm\#syntax
49
7a8b9bd9
VS
50In this example, the protocol is "zip", right location is
51"reference/fopen.htm", anchor is "syntax" and left location
f6bcfd97 52is "file:archives/cpp\_doc.zip".
704a4b75 53
f6bcfd97 54There are {\bf two} protocols used in this example: "zip" and "file".
704a4b75
VS
55
56\wxheading{File Systems Included in wxHTML}
57
fc2171bd 58The following virtual file system handlers are part of wxWidgets so far:
cadd476d
VS
59
60\begin{twocollist}
aa0ff209
MW
61\twocolitem{{\bf wxArchiveFSHandler}}{A handler for archives such as zip
62and tar. Include file is <wx/fs\_arc.h>. URLs examples:
63"archive.zip\#zip:filename", "archive.tar.gz\#gzip:\#tar:filename".}
64\twocolitem{{\bf wxFilterFSHandler}}{A handler for compression schemes such
65as gzip. Header is <wx/fs\_filter.h>. URLs are in the form, e.g.:
66"document.ps.gz\#gzip:".}
f6bcfd97 67\twocolitem{{\bf wxInternetFSHandler}}{A handler for accessing documents
e7240349 68via HTTP or FTP protocols. Include file is <wx/fs\_inet.h>.}
cadd476d
VS
69\twocolitem{{\bf wxMemoryFSHandler}}{This handler allows you to access
70data stored in memory (such as bitmaps) as if they were regular files.
71See \helpref{wxMemoryFSHandler documentation}{wxmemoryfshandler} for details.
2edb0bde 72Include file is <wx/fs\_mem.h>. URL is prefixed with memory:, e.g.
cadd476d
VS
73"memory:myfile.htm"}
74\end{twocollist}
75
f6bcfd97
BP
76In addition, wxFileSystem itself can access local files.
77
cadd476d 78
f6bcfd97 79\wxheading{Initializing file system handlers}
cadd476d
VS
80
81Use \helpref{wxFileSystem::AddHandler}{wxfilesystemaddhandler} to initialize
82a handler, for example:
83
84\begin{verbatim}
85#include <wx/fs_mem.h>
86
87...
88
89bool MyApp::OnInit()
90{
91 wxFileSystem::AddHandler(new wxMemoryFSHandler);
92...
f6bcfd97 93}
cadd476d
VS
94\end{verbatim}
95