]>
Commit | Line | Data |
---|---|---|
704a4b75 VS |
1 | \section{File Systems}\label{fs} |
2 | ||
b453e1b2 RR |
3 | The wxHTML library uses a {\bf virtual file systems} mechanism |
4 | similar to the one used in Midnight Commander, Dos Navigator, | |
704a4b75 | 5 | FAR or almost any modern file manager. (Do you remember? You can |
b453e1b2 RR |
6 | press enter on ZIP file and its contents is displayed as if it |
7 | were a local directory...) | |
704a4b75 VS |
8 | |
9 | \wxheading{Classes} | |
10 | ||
11 | Three classes are used in order to provide full VFS: | |
12 | ||
13 | \begin{itemize} | |
b453e1b2 | 14 | \item The \helpref{wxFSFile}{wxfsfile} class provides information |
704a4b75 VS |
15 | on opened file (name, input stream, mime type and anchor). |
16 | ||
b453e1b2 RR |
17 | \item The \helpref{wxFileSystem}{wxfilesystem} class is the interface. |
18 | Its main methods are ChangePathTo() and OpenFile(). This class | |
704a4b75 VS |
19 | is most often used by the end user. |
20 | ||
b453e1b2 | 21 | \item The \helpref{wxFileSystemHandler}{wxfilesystemhandler} is the core |
704a4b75 VS |
22 | if VFS mechanism. You can derive your own handler and pass it to |
23 | wxFileSystem's AddHandler() method. In the new handler you only need to | |
24 | overwrite OpenFile() and CanOpen() methods. | |
25 | \end{itemize} | |
26 | ||
27 | \wxheading{Locations} | |
28 | ||
29 | Locations (aka filenames aka addresses) are constructed from 4 parts: | |
30 | ||
31 | \begin{itemize} | |
b453e1b2 RR |
32 | \item {\bf protocol} - handler can recognize if it is able to open a |
33 | file by checking its protocol. Examples are "http", "file" or "ftp". | |
704a4b75 VS |
34 | |
35 | \item {\bf right location} - is the name of file within the protocol. | |
b453e1b2 | 36 | In "http://www.wxwindows.org/index.html" the right location is "//www.wxwindows.org/index.html". |
704a4b75 VS |
37 | |
38 | \item {\bf anchor} - anchor is optional and is usually not present. | |
b453e1b2 | 39 | In "index.htm\#chapter2" the anchor is "chapter2". |
704a4b75 | 40 | |
b453e1b2 | 41 | \item {\bf left location} - this is usually an empty string. |
704a4b75 VS |
42 | It is used by 'local' protocols such as ZIP. |
43 | See Combined Protocols paragraph for details. | |
44 | \end{itemize} | |
45 | ||
46 | \wxheading{Combined Protocols} | |
47 | ||
48 | Left location pretends protocol in URL string. | |
49 | It's not used by global protocols like HTTP but it's used | |
50 | by local ones - for example you can see this address: | |
51 | ||
52 | file:archives/cpp\_doc.zip\#zip:reference/fopen.htm\#syntax | |
53 | ||
54 | In this example, protocol is "zip", left location is | |
55 | "reference/fopen.htm", anchor is "syntax" and right location | |
56 | is "file:archives/cpp_doc.zip". It is used by zip handler | |
57 | to determine in what file this particular zip VFS is stored. | |
58 | ||
b453e1b2 | 59 | In fact there are two protocols used in this example: zip and file. |
704a4b75 VS |
60 | You can construct even more complicated addresses like this one: |
61 | ||
62 | http://www.archives.org/myarchive.zip\#zip:local/docs/cpp/stdio.zip\#zip:index.htm | |
63 | ||
64 | In this example you access zip VFS stdio.zip stored in another zip (myarchive.zip) | |
b453e1b2 | 65 | which is at WWW. |
704a4b75 VS |
66 | |
67 | \wxheading{File Systems Included in wxHTML} | |
68 | ||
69 | \begin{enumerate} | |
70 | \item Local files | |
71 | \item HTTP protocol | |
72 | \item FTP protocol | |
73 | \item .ZIP archives | |
74 | \end{enumerate} | |
75 |