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 #include "wx/bitmap.h"
22 // ----------------------------------------------------------------------------
23 // wxMemoryFSHandlerBase
24 // ----------------------------------------------------------------------------
26 class WXDLLIMPEXP_BASE wxMemoryFSHandlerBase
: public wxFileSystemHandler
29 wxMemoryFSHandlerBase();
30 virtual ~wxMemoryFSHandlerBase();
32 // Add file to list of files stored in memory. Stored data (bitmap, text or
33 // raw data) will be copied into private memory stream and available under
34 // name "memory:" + filename
35 static void AddFile(const wxString
& filename
, const wxString
& textdata
);
36 static void AddFile(const wxString
& filename
, const void *binarydata
, size_t size
);
37 static void AddFileWithMimeType(const wxString
& filename
,
38 const wxString
& textdata
,
39 const wxString
& mimetype
);
40 static void AddFileWithMimeType(const wxString
& filename
,
41 const void *binarydata
, size_t size
,
42 const wxString
& mimetype
);
44 // Remove file from memory FS and free occupied memory
45 static void RemoveFile(const wxString
& filename
);
47 virtual bool CanOpen(const wxString
& location
);
48 virtual wxFSFile
* OpenFile(wxFileSystem
& fs
, const wxString
& location
);
49 virtual wxString
FindFirst(const wxString
& spec
, int flags
= 0);
50 virtual wxString
FindNext();
53 static bool CheckHash(const wxString
& filename
);
54 static wxHashTable
*m_Hash
;
57 // ----------------------------------------------------------------------------
59 // ----------------------------------------------------------------------------
63 // add GUI-only operations to the base class
64 class WXDLLIMPEXP_CORE wxMemoryFSHandler
: public wxMemoryFSHandlerBase
67 // bring the base class versions into the scope, otherwise they would be
68 // inaccessible in wxMemoryFSHandler
69 // (unfortunately "using" can't be used as gcc 2.95 doesn't have it...)
70 static void AddFile(const wxString
& filename
, const wxString
& textdata
)
72 wxMemoryFSHandlerBase::AddFile(filename
, textdata
);
75 static void AddFile(const wxString
& filename
,
76 const void *binarydata
,
79 wxMemoryFSHandlerBase::AddFile(filename
, binarydata
, size
);
81 static void AddFileWithMimeType(const wxString
& filename
,
82 const wxString
& textdata
,
83 const wxString
& mimetype
)
85 wxMemoryFSHandlerBase::AddFileWithMimeType(filename
,
89 static void AddFileWithMimeType(const wxString
& filename
,
90 const void *binarydata
, size_t size
,
91 const wxString
& mimetype
)
93 wxMemoryFSHandlerBase::AddFileWithMimeType(filename
,
99 static void AddFile(const wxString
& filename
,
100 const wxImage
& image
,
103 static void AddFile(const wxString
& filename
,
104 const wxBitmap
& bitmap
,
106 #endif // wxUSE_IMAGE
112 // just the same thing as the base class in wxBase
113 class WXDLLIMPEXP_BASE wxMemoryFSHandler
: public wxMemoryFSHandlerBase
117 #endif // wxUSE_GUI/!wxUSE_GUI
119 #endif // wxUSE_FILESYSTEM
121 #endif // _WX_FS_MEM_H_