]>
Commit | Line | Data |
---|---|---|
dcb86da0 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: fs_mem.h | |
3 | // Purpose: in-memory file system | |
4 | // Author: Vaclav Slavik | |
5 | // Copyright: (c) 2000 Vaclav Slavik | |
6 | // Licence: wxWindows Licence | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
4e8e18e2 VZ |
9 | #ifndef _WX_FS_MEM_H_ |
10 | #define _WX_FS_MEM_H_ | |
dcb86da0 | 11 | |
af49c4b8 | 12 | #if defined(__GNUG__) && !defined(__APPLE__) |
c3f4609e | 13 | #pragma interface "fs_mem.h" |
dcb86da0 VS |
14 | #endif |
15 | ||
16 | #include "wx/wxprec.h" | |
17 | ||
2b5f62a0 | 18 | #ifdef __BORLANDC__ |
dcb86da0 VS |
19 | #pragma hdrstop |
20 | #endif | |
21 | ||
24528b0c | 22 | #if wxUSE_FILESYSTEM |
dcb86da0 | 23 | |
dcb86da0 | 24 | #include "wx/filesys.h" |
04dbb646 | 25 | |
886dd7d2 | 26 | #if wxUSE_GUI |
bddd7a8d VZ |
27 | class WXDLLIMPEXP_CORE wxBitmap; |
28 | class WXDLLIMPEXP_CORE wxImage; | |
886dd7d2 | 29 | #endif // wxUSE_GUI |
dcb86da0 | 30 | |
a8f12b67 VZ |
31 | // ---------------------------------------------------------------------------- |
32 | // wxMemoryFSHandlerBase | |
33 | // ---------------------------------------------------------------------------- | |
dcb86da0 | 34 | |
bddd7a8d | 35 | class WXDLLIMPEXP_BASE wxMemoryFSHandlerBase : public wxFileSystemHandler |
dcb86da0 | 36 | { |
e2478fde VZ |
37 | public: |
38 | wxMemoryFSHandlerBase(); | |
39 | ~wxMemoryFSHandlerBase(); | |
dcb86da0 | 40 | |
e2478fde VZ |
41 | // Add file to list of files stored in memory. Stored data (bitmap, text or |
42 | // raw data) will be copied into private memory stream and available under | |
43 | // name "memory:" + filename | |
e2478fde VZ |
44 | static void AddFile(const wxString& filename, const wxString& textdata); |
45 | static void AddFile(const wxString& filename, const void *binarydata, size_t size); | |
04dbb646 | 46 | |
e2478fde VZ |
47 | // Remove file from memory FS and free occupied memory |
48 | static void RemoveFile(const wxString& filename); | |
04dbb646 | 49 | |
e2478fde VZ |
50 | virtual bool CanOpen(const wxString& location); |
51 | virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location); | |
52 | virtual wxString FindFirst(const wxString& spec, int flags = 0); | |
53 | virtual wxString FindNext(); | |
04dbb646 | 54 | |
60c0a8db | 55 | protected: |
e2478fde | 56 | static bool CheckHash(const wxString& filename); |
60c0a8db | 57 | static wxHashTable *m_Hash; |
dcb86da0 VS |
58 | }; |
59 | ||
a8f12b67 VZ |
60 | // ---------------------------------------------------------------------------- |
61 | // wxMemoryFSHandler | |
62 | // ---------------------------------------------------------------------------- | |
63 | ||
64 | #if wxUSE_GUI | |
65 | ||
66 | // add GUI-only operations to the base class | |
67 | class WXDLLIMPEXP_CORE wxMemoryFSHandler : public wxMemoryFSHandlerBase | |
e2478fde VZ |
68 | { |
69 | public: | |
a8f12b67 VZ |
70 | // bring the base class versions into the scope, otherwise they would be |
71 | // inaccessible in wxMemoryFSHandler | |
192a6c88 VZ |
72 | // (unfortunately "using" can't be used as gcc 2.95 doesn't have it...) |
73 | static void AddFile(const wxString& filename, const wxString& textdata) | |
74 | { | |
75 | wxMemoryFSHandlerBase::AddFile(filename, textdata); | |
76 | } | |
77 | ||
78 | static void AddFile(const wxString& filename, | |
79 | const void *binarydata, | |
80 | size_t size) | |
81 | { | |
82 | wxMemoryFSHandlerBase::AddFile(filename, binarydata, size); | |
83 | } | |
a8f12b67 | 84 | |
2de5a6ee VS |
85 | #if wxUSE_IMAGE |
86 | static void AddFile(const wxString& filename, wxImage& image, long type); | |
87 | #endif // wxUSE_IMAGE | |
a8f12b67 | 88 | |
192a6c88 VZ |
89 | static void AddFile(const wxString& filename, |
90 | const wxBitmap& bitmap, | |
91 | long type); | |
e2478fde | 92 | }; |
dcb86da0 | 93 | |
a8f12b67 VZ |
94 | #else // !wxUSE_GUI |
95 | ||
96 | // just the same thing as the base class in wxBase | |
97 | class WXDLLIMPEXP_BASE wxMemoryFSHandler : public wxMemoryFSHandlerBase | |
98 | { | |
99 | }; | |
100 | ||
101 | #endif // wxUSE_GUI/!wxUSE_GUI | |
102 | ||
e2478fde | 103 | #endif // wxUSE_FILESYSTEM |
dcb86da0 | 104 | |
4e8e18e2 VZ |
105 | #endif // _WX_FS_MEM_H_ |
106 |