filesystem.h 3.7 KB

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