aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/sdl/win32/win32.cpp86
-rw-r--r--backends/platform/sdl/win32/win32.h1
2 files changed, 87 insertions, 0 deletions
diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp
index fffc3a2a75..d6a39ff48f 100644
--- a/backends/platform/sdl/win32/win32.cpp
+++ b/backends/platform/sdl/win32/win32.cpp
@@ -39,6 +39,8 @@
#include "backends/platform/sdl/win32/win32.h"
#include "backends/fs/windows/windows-fs-factory.h"
+#include "common/memstream.h"
+
#define DEFAULT_CONFIG_FILE "scummvm.ini"
//#define HIDE_CONSOLE
@@ -170,4 +172,88 @@ Common::WriteStream *OSystem_Win32::createLogFile() {
}
}
+namespace {
+
+class Win32ResourceArchive : public Common::Archive {
+ friend BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam);
+public:
+ Win32ResourceArchive();
+
+ virtual bool hasFile(const Common::String &name);
+ virtual int listMembers(Common::ArchiveMemberList &list);
+ virtual Common::ArchiveMemberPtr getMember(const Common::String &name);
+ virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
+private:
+ typedef Common::List<Common::String> FilenameList;
+
+ FilenameList _files;
+};
+
+BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam) {
+ if (IS_INTRESOURCE(lpszName))
+ return TRUE;
+
+ Win32ResourceArchive *arch = (Win32ResourceArchive *)lParam;
+ arch->_files.push_back(lpszName);
+ return TRUE;
+}
+
+Win32ResourceArchive::Win32ResourceArchive() {
+ EnumResourceNames(NULL, MAKEINTRESOURCE(256), &EnumResNameProc, (LONG_PTR)this);
+}
+
+bool Win32ResourceArchive::hasFile(const Common::String &name) {
+ for (FilenameList::const_iterator i = _files.begin(); i != _files.end(); ++i) {
+ if (i->equalsIgnoreCase(name))
+ return true;
+ }
+
+ return false;
+}
+
+int Win32ResourceArchive::listMembers(Common::ArchiveMemberList &list) {
+ int count = 0;
+
+ for (FilenameList::const_iterator i = _files.begin(); i != _files.end(); ++i, ++count)
+ list.push_back(Common::ArchiveMemberPtr(new Common::GenericArchiveMember(*i, this)));
+
+ return count;
+}
+
+Common::ArchiveMemberPtr Win32ResourceArchive::getMember(const Common::String &name) {
+ return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
+}
+
+Common::SeekableReadStream *Win32ResourceArchive::createReadStreamForMember(const Common::String &name) const {
+ HRSRC resource = FindResource(NULL, name.c_str(), MAKEINTRESOURCE(256));
+
+ if (resource == NULL)
+ return 0;
+
+ HGLOBAL handle = LoadResource(NULL, resource);
+
+ if (handle == NULL)
+ return 0;
+
+ const byte *data = (const byte *)LockResource(handle);
+
+ if (data == NULL)
+ return 0;
+
+ uint32 size = SizeofResource(NULL, resource);
+
+ if (size == 0)
+ return 0;
+
+ return new Common::MemoryReadStream(data, size);
+}
+
+} // End of anonymous namespace
+
+void OSystem_Win32::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
+ s.add("Win32Res", new Win32ResourceArchive());
+
+ OSystem_SDL::addSysArchivesToSearchSet(s, priority);
+}
+
#endif
diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h
index 8379c49437..25cb6bfbba 100644
--- a/backends/platform/sdl/win32/win32.h
+++ b/backends/platform/sdl/win32/win32.h
@@ -32,6 +32,7 @@ class OSystem_Win32 : public OSystem_SDL {
public:
virtual void init();
+ virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
protected:
virtual Common::String getDefaultConfigFileName();
virtual Common::WriteStream *createLogFile();