From 8c180c05f35ef70efb7bbf4c9150d04da310d0b4 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 21 Jun 2007 15:26:35 +0000 Subject: [PATCH] Added MemoryFSHandler.AddFileWithMimeType git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@46591 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/_filesys.i | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/wxPython/src/_filesys.i b/wxPython/src/_filesys.i index fa76da3e68..953bec16cf 100644 --- a/wxPython/src/_filesys.i +++ b/wxPython/src/_filesys.i @@ -245,7 +245,7 @@ public: wxPyEndBlockThreads(blocked); wxMemoryFSHandler::AddFile(filename, ptr, size); - } + } %} @@ -280,6 +280,26 @@ public: // Add a file to the memory FS %pythoncode { AddFile = staticmethod(MemoryFSHandler_AddFile) } + %extend { + static void AddFileWithMimeType(const wxString& filename, + PyObject* data, + const wxString& mimetype) + { + if (! PyString_Check(data)) { + wxPyBLOCK_THREADS(PyErr_SetString(PyExc_TypeError, + "Expected string object")); + return; + } + + wxPyBlock_t blocked = wxPyBeginBlockThreads(); + void* ptr = (void*)PyString_AsString(data); + size_t size = PyString_Size(data); + wxPyEndBlockThreads(blocked); + + wxMemoryFSHandler::AddFileWithMimeType(filename, ptr, size, mimetype); + } + } + bool CanOpen(const wxString& location); %newobject OpenFile; wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);