]>
Commit | Line | Data |
---|---|---|
15b6757b | 1 | ///////////////////////////////////////////////////////////////////////////// |
3b88355f | 2 | // Name: filesystem.h |
15b6757b FM |
3 | // Purpose: topic overview |
4 | // Author: wxWidgets team | |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /*! | |
36c9828f | 10 | |
3b88355f | 11 | @page overview_fs wxFileSystem overview |
36c9828f | 12 | |
15b6757b FM |
13 | The wxHTML library uses a @b virtual file systems mechanism |
14 | similar to the one used in Midnight Commander, Dos Navigator, | |
15 | FAR or almost any modern file manager. It allows the user to access | |
16 | data stored in archives as if they were ordinary files. On-the-fly | |
17 | generated files that exist only in memory are also supported. | |
3b88355f FM |
18 | |
19 | @li @ref overview_fs_classes | |
20 | @li @ref overview_fs_locations | |
21 | @li @ref overview_fs_combined | |
22 | @li @ref overview_fs_wxhtmlfs | |
23 | @li @ref overview_fs_init | |
24 | ||
25 | ||
26 | <hr> | |
27 | ||
28 | ||
29 | @section overview_fs_classes Classes | |
30 | ||
15b6757b | 31 | Three classes are used in order to provide virtual file systems mechanism: |
36c9828f | 32 | |
98ba1eee | 33 | @li The wxFSFile class provides information |
3b88355f | 34 | about opened file (name, input stream, mime type and anchor). |
98ba1eee | 35 | @li The wxFileSystem class is the interface. |
3b88355f FM |
36 | Its main methods are ChangePathTo() and OpenFile(). This class |
37 | is most often used by the end user. | |
98ba1eee | 38 | @li The wxFileSystemHandler is the core |
3b88355f FM |
39 | of virtual file systems mechanism. You can derive your own handler and pass |
40 | it to the VFS mechanism. You can derive your own handler and pass it to | |
41 | wxFileSystem's AddHandler() method. In the new handler you only need to | |
42 | override the OpenFile() and CanOpen() methods. | |
36c9828f | 43 | |
36c9828f | 44 | |
3b88355f | 45 | @section overview_fs_locations Locations |
36c9828f | 46 | |
15b6757b | 47 | Locations (aka filenames aka addresses) are constructed from four parts: |
36c9828f | 48 | |
3b88355f FM |
49 | @li @b protocol - handler can recognize if it is able to open a |
50 | file by checking its protocol. Examples are "http", "file" or "ftp". | |
51 | @li <b>right location</b> - is the name of file within the protocol. | |
52 | In "http://www.wxwidgets.org/index.html" the right location is "//www.wxwidgets.org/index.html". | |
53 | @li @b anchor - an anchor is optional and is usually not present. | |
54 | In "index.htm#chapter2" the anchor is "chapter2". | |
55 | @li <b>left location</b> - this is usually an empty string. | |
56 | It is used by 'local' protocols such as ZIP. | |
57 | See Combined Protocols paragraph for details. | |
36c9828f | 58 | |
36c9828f | 59 | |
3b88355f | 60 | @section overview_fs_combined Combined Protocols |
36c9828f | 61 | |
36c9828f | 62 | The left location precedes the protocol in the URL string. |
3b88355f | 63 | |
15b6757b FM |
64 | It is not used by global protocols like HTTP but it becomes handy when nesting |
65 | protocols - for example you may want to access files in a ZIP archive: | |
66 | file:archives/cpp_doc.zip#zip:reference/fopen.htm#syntax | |
67 | In this example, the protocol is "zip", right location is | |
68 | "reference/fopen.htm", anchor is "syntax" and left location | |
36c9828f | 69 | is "file:archives/cpp_doc.zip". |
36c9828f | 70 | |
3b88355f | 71 | There are @b two protocols used in this example: "zip" and "file". |
36c9828f FM |
72 | |
73 | ||
3b88355f | 74 | @section overview_fs_wxhtmlfs File Systems Included in wxHTML |
36c9828f | 75 | |
3b88355f | 76 | The following virtual file system handlers are part of wxWidgets so far: |
36c9828f | 77 | |
3b88355f FM |
78 | @li @b wxArchiveFSHandler: |
79 | A handler for archives such as zip | |
80 | and tar. Include file is wx/fs_arc.h. URLs examples: | |
81 | "archive.zip#zip:filename", "archive.tar.gz#gzip:#tar:filename". | |
82 | @li @b wxFilterFSHandler: | |
83 | A handler for compression schemes such | |
84 | as gzip. Header is wx/fs_filter.h. URLs are in the form, e.g.: | |
85 | "document.ps.gz#gzip:". | |
86 | @li @b wxInternetFSHandler: | |
87 | A handler for accessing documents | |
88 | via HTTP or FTP protocols. Include file is wx/fs_inet.h. | |
89 | @li @b wxMemoryFSHandler: | |
90 | This handler allows you to access | |
91 | data stored in memory (such as bitmaps) as if they were regular files. | |
58fa97d1 | 92 | See wxMemoryFSHandler for details. |
3b88355f FM |
93 | Include file is wx/fs_mem.h. URL is prefixed with memory:, e.g. |
94 | "memory:myfile.htm" | |
36c9828f | 95 | |
3b88355f | 96 | In addition, wxFileSystem itself can access local files. |
36c9828f FM |
97 | |
98 | ||
3b88355f | 99 | @section overview_fs_init Initializing file system handlers |
36c9828f | 100 | |
3b88355f | 101 | Use wxFileSystem::AddHandler to initialize a handler, for example: |
36c9828f | 102 | |
15b6757b | 103 | @code |
3b88355f | 104 | #include <wx/fs_mem.h> |
36c9828f | 105 | |
15b6757b | 106 | ... |
36c9828f | 107 | |
15b6757b FM |
108 | bool MyApp::OnInit() |
109 | { | |
110 | wxFileSystem::AddHandler(new wxMemoryFSHandler); | |
111 | ... | |
112 | } | |
113 | @endcode | |
36c9828f | 114 | |
3b88355f | 115 | */ |
36c9828f | 116 |