]> git.saurik.com Git - wxWidgets.git/blob - include/wx/fs_mem.h
fixed Cygwin compilation (there's no _get_osfhandle)
[wxWidgets.git] / include / wx / fs_mem.h
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
9 #ifndef _WX_FS_MEM_H_
10 #define _WX_FS_MEM_H_
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) && !defined(__EMX__)
13 // Some older compilers (such as EMX) cannot handle
14 // #pragma interface/implementation correctly, iff
15 // #pragma implementation is used in _two_ translation
16 // units (as created by e.g. event.cpp compiled for
17 // libwx_base and event.cpp compiled for libwx_gui_core).
18 // So we must not use those pragmas for those compilers in
19 // such files.
20 #pragma interface "fs_mem.h"
21 #endif
22
23 #include "wx/defs.h"
24
25 #if wxUSE_FILESYSTEM
26
27 #include "wx/filesys.h"
28
29 #if wxUSE_GUI
30 class WXDLLIMPEXP_CORE wxBitmap;
31 class WXDLLIMPEXP_CORE wxImage;
32 #endif // wxUSE_GUI
33
34 // ----------------------------------------------------------------------------
35 // wxMemoryFSHandlerBase
36 // ----------------------------------------------------------------------------
37
38 class WXDLLIMPEXP_BASE wxMemoryFSHandlerBase : public wxFileSystemHandler
39 {
40 public:
41 wxMemoryFSHandlerBase();
42 ~wxMemoryFSHandlerBase();
43
44 // Add file to list of files stored in memory. Stored data (bitmap, text or
45 // raw data) will be copied into private memory stream and available under
46 // name "memory:" + filename
47 static void AddFile(const wxString& filename, const wxString& textdata);
48 static void AddFile(const wxString& filename, const void *binarydata, size_t size);
49
50 // Remove file from memory FS and free occupied memory
51 static void RemoveFile(const wxString& filename);
52
53 virtual bool CanOpen(const wxString& location);
54 virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
55 virtual wxString FindFirst(const wxString& spec, int flags = 0);
56 virtual wxString FindNext();
57
58 protected:
59 static bool CheckHash(const wxString& filename);
60 static wxHashTable *m_Hash;
61 };
62
63 // ----------------------------------------------------------------------------
64 // wxMemoryFSHandler
65 // ----------------------------------------------------------------------------
66
67 #if wxUSE_GUI
68
69 // add GUI-only operations to the base class
70 class WXDLLIMPEXP_CORE wxMemoryFSHandler : public wxMemoryFSHandlerBase
71 {
72 public:
73 // bring the base class versions into the scope, otherwise they would be
74 // inaccessible in wxMemoryFSHandler
75 // (unfortunately "using" can't be used as gcc 2.95 doesn't have it...)
76 static void AddFile(const wxString& filename, const wxString& textdata)
77 {
78 wxMemoryFSHandlerBase::AddFile(filename, textdata);
79 }
80
81 static void AddFile(const wxString& filename,
82 const void *binarydata,
83 size_t size)
84 {
85 wxMemoryFSHandlerBase::AddFile(filename, binarydata, size);
86 }
87
88 #if wxUSE_IMAGE
89 static void AddFile(const wxString& filename,
90 const wxImage& image,
91 long type);
92
93 static void AddFile(const wxString& filename,
94 const wxBitmap& bitmap,
95 long type);
96 #endif // wxUSE_IMAGE
97
98 };
99
100 #else // !wxUSE_GUI
101
102 // just the same thing as the base class in wxBase
103 class WXDLLIMPEXP_BASE wxMemoryFSHandler : public wxMemoryFSHandlerBase
104 {
105 };
106
107 #endif // wxUSE_GUI/!wxUSE_GUI
108
109 #endif // wxUSE_FILESYSTEM
110
111 #endif // _WX_FS_MEM_H_
112