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