1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: in-memory file system
4 // Author: Vaclav Slavik
5 // Copyright: (c) 2000 Vaclav Slavik
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
16 #include "wx/filesys.h"
19 class WXDLLIMPEXP_FWD_CORE wxBitmap
;
20 class WXDLLIMPEXP_FWD_CORE wxImage
;
23 // ----------------------------------------------------------------------------
24 // wxMemoryFSHandlerBase
25 // ----------------------------------------------------------------------------
27 class WXDLLIMPEXP_BASE wxMemoryFSHandlerBase
: public wxFileSystemHandler
30 wxMemoryFSHandlerBase();
31 virtual ~wxMemoryFSHandlerBase();
33 // Add file to list of files stored in memory. Stored data (bitmap, text or
34 // raw data) will be copied into private memory stream and available under
35 // name "memory:" + filename
36 static void AddFile(const wxString
& filename
, const wxString
& textdata
);
37 static void AddFile(const wxString
& filename
, const void *binarydata
, size_t size
);
38 static void AddFileWithMimeType(const wxString
& filename
,
39 const wxString
& textdata
,
40 const wxString
& mimetype
);
41 static void AddFileWithMimeType(const wxString
& filename
,
42 const void *binarydata
, size_t size
,
43 const wxString
& mimetype
);
45 // Remove file from memory FS and free occupied memory
46 static void RemoveFile(const wxString
& filename
);
48 virtual bool CanOpen(const wxString
& location
);
49 virtual wxFSFile
* OpenFile(wxFileSystem
& fs
, const wxString
& location
);
50 virtual wxString
FindFirst(const wxString
& spec
, int flags
= 0);
51 virtual wxString
FindNext();
54 static bool CheckHash(const wxString
& filename
);
55 static wxHashTable
*m_Hash
;
58 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
64 // add GUI-only operations to the base class
65 class WXDLLIMPEXP_CORE wxMemoryFSHandler
: public wxMemoryFSHandlerBase
68 // bring the base class versions into the scope, otherwise they would be
69 // inaccessible in wxMemoryFSHandler
70 // (unfortunately "using" can't be used as gcc 2.95 doesn't have it...)
71 static void AddFile(const wxString
& filename
, const wxString
& textdata
)
73 wxMemoryFSHandlerBase::AddFile(filename
, textdata
);
76 static void AddFile(const wxString
& filename
,
77 const void *binarydata
,
80 wxMemoryFSHandlerBase::AddFile(filename
, binarydata
, size
);
82 static void AddFileWithMimeType(const wxString
& filename
,
83 const wxString
& textdata
,
84 const wxString
& mimetype
)
86 wxMemoryFSHandlerBase::AddFileWithMimeType(filename
,
90 static void AddFileWithMimeType(const wxString
& filename
,
91 const void *binarydata
, size_t size
,
92 const wxString
& mimetype
)
94 wxMemoryFSHandlerBase::AddFileWithMimeType(filename
,
100 static void AddFile(const wxString
& filename
,
101 const wxImage
& image
,
104 static void AddFile(const wxString
& filename
,
105 const wxBitmap
& bitmap
,
107 #endif // wxUSE_IMAGE
113 // just the same thing as the base class in wxBase
114 class WXDLLIMPEXP_BASE wxMemoryFSHandler
: public wxMemoryFSHandlerBase
118 #endif // wxUSE_GUI/!wxUSE_GUI
120 #endif // wxUSE_FILESYSTEM
122 #endif // _WX_FS_MEM_H_