]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/fs.tex
Fixed crash-on-exit bug due to status bar being deleted twice (MDI apps);
[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,
704a4b75 5FAR or almost any modern file manager. (Do you remember? You can
b453e1b2
RR
6press enter on ZIP file and its contents is displayed as if it
7were a local directory...)
704a4b75
VS
8
9\wxheading{Classes}
10
11Three classes are used in order to provide full VFS:
12
22d6efa8 13\begin{itemize}\itemsep=0pt
b453e1b2 14\item The \helpref{wxFSFile}{wxfsfile} class provides information
704a4b75 15on 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
704a4b75
VS
20if VFS mechanism. You can derive your own handler and pass it to
21wxFileSystem's AddHandler() method. In the new handler you only need to
22overwrite OpenFile() and CanOpen() methods.
23\end{itemize}
24
25\wxheading{Locations}
26
27Locations (aka filenames aka addresses) are constructed from 4 parts:
28
22d6efa8 29\begin{itemize}\itemsep=0pt
b453e1b2
RR
30\item {\bf protocol} - handler can recognize if it is able to open a
31file by checking its protocol. Examples are "http", "file" or "ftp".
704a4b75 32\item {\bf right location} - is the name of file within the protocol.
b453e1b2 33In "http://www.wxwindows.org/index.html" the right location is "//www.wxwindows.org/index.html".
704a4b75 34\item {\bf anchor} - anchor is optional and is usually not present.
b453e1b2 35In "index.htm\#chapter2" the anchor is "chapter2".
b453e1b2 36\item {\bf left location} - this is usually an empty string.
704a4b75
VS
37It is used by 'local' protocols such as ZIP.
38See Combined Protocols paragraph for details.
39\end{itemize}
40
41\wxheading{Combined Protocols}
42
43Left location pretends protocol in URL string.
44It's not used by global protocols like HTTP but it's used
45by local ones - for example you can see this address:
46
47file:archives/cpp\_doc.zip\#zip:reference/fopen.htm\#syntax
48
49In this example, protocol is "zip", left location is
50"reference/fopen.htm", anchor is "syntax" and right location
605d715d 51is "file:archives/cpp\_doc.zip". It is used by zip handler
704a4b75
VS
52to determine in what file this particular zip VFS is stored.
53
b453e1b2 54In fact there are two protocols used in this example: zip and file.
704a4b75
VS
55You can construct even more complicated addresses like this one:
56
57http://www.archives.org/myarchive.zip\#zip:local/docs/cpp/stdio.zip\#zip:index.htm
58
59In this example you access zip VFS stdio.zip stored in another zip (myarchive.zip)
b453e1b2 60which is at WWW.
704a4b75
VS
61
62\wxheading{File Systems Included in wxHTML}
63
cadd476d
VS
64Following VFS handlers are part of wxWindows so far:
65
66\begin{twocollist}
67\twocolitem{{\bf wxInternetFSHandler}}{Handler for accessing documents
68via HTTP or FTP protocols. Include file is <wx/fs_inet.h>.}
69\twocolitem{{\bf wxZipFSHandler}}{Handler for ZIP archives.
70Include file is <wx/fs_zip.h>. URL is in form "archive.zip\#zip:filename".}
71\twocolitem{{\bf wxMemoryFSHandler}}{This handler allows you to access
72data stored in memory (such as bitmaps) as if they were regular files.
73See \helpref{wxMemoryFSHandler documentation}{wxmemoryfshandler} for details.
74Include file is <wx/fs_mem.h>. UURL is prefixed with memory:, e.g.
75"memory:myfile.htm"}
76\end{twocollist}
77
78In addition, wxFileSystem can access local files.
79
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...
93\end{verbatim}
94
95
704a4b75 96