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"
21 #include "wx/bitmap.h"
24 // ----------------------------------------------------------------------------
25 // wxMemoryFSHandlerBase
26 // ----------------------------------------------------------------------------
28 class WXDLLIMPEXP_BASE wxMemoryFSHandlerBase
: public wxFileSystemHandler
31 wxMemoryFSHandlerBase();
32 virtual ~wxMemoryFSHandlerBase();
34 // Add file to list of files stored in memory. Stored data (bitmap, text or
35 // raw data) will be copied into private memory stream and available under
36 // name "memory:" + filename
37 static void AddFile(const wxString
& filename
, const wxString
& textdata
);
38 static void AddFile(const wxString
& filename
, const void *binarydata
, size_t size
);
39 static void AddFileWithMimeType(const wxString
& filename
,
40 const wxString
& textdata
,
41 const wxString
& mimetype
);
42 static void AddFileWithMimeType(const wxString
& filename
,
43 const void *binarydata
, size_t size
,
44 const wxString
& mimetype
);
46 // Remove file from memory FS and free occupied memory
47 static void RemoveFile(const wxString
& filename
);
49 virtual bool CanOpen(const wxString
& location
);
50 virtual wxFSFile
* OpenFile(wxFileSystem
& fs
, const wxString
& location
);
51 virtual wxString
FindFirst(const wxString
& spec
, int flags
= 0);
52 virtual wxString
FindNext();
55 static bool CheckHash(const wxString
& filename
);
56 static wxMemoryFSHash
*m_Hash
;
59 // ----------------------------------------------------------------------------
61 // ----------------------------------------------------------------------------
65 // add GUI-only operations to the base class
66 class WXDLLIMPEXP_CORE wxMemoryFSHandler
: public wxMemoryFSHandlerBase
69 // bring the base class versions into the scope, otherwise they would be
70 // inaccessible in wxMemoryFSHandler
71 // (unfortunately "using" can't be used as gcc 2.95 doesn't have it...)
72 static void AddFile(const wxString
& filename
, const wxString
& textdata
)
74 wxMemoryFSHandlerBase
::AddFile(filename
, textdata
);
77 static void AddFile(const wxString
& filename
,
78 const void *binarydata
,
81 wxMemoryFSHandlerBase
::AddFile(filename
, binarydata
, size
);
83 static void AddFileWithMimeType(const wxString
& filename
,
84 const wxString
& textdata
,
85 const wxString
& mimetype
)
87 wxMemoryFSHandlerBase
::AddFileWithMimeType(filename
,
91 static void AddFileWithMimeType(const wxString
& filename
,
92 const void *binarydata
, size_t size
,
93 const wxString
& mimetype
)
95 wxMemoryFSHandlerBase
::AddFileWithMimeType(filename
,
101 static void AddFile(const wxString
& filename
,
102 const wxImage
& image
,
105 static void AddFile(const wxString
& filename
,
106 const wxBitmap
& bitmap
,
108 #endif // wxUSE_IMAGE
114 // just the same thing as the base class in wxBase
115 class WXDLLIMPEXP_BASE wxMemoryFSHandler
: public wxMemoryFSHandlerBase
119 #endif // wxUSE_GUI/!wxUSE_GUI
121 #endif // wxUSE_FILESYSTEM
123 #endif // _WX_FS_MEM_H_