Add wxFSInputStream providing stream interface to wxFileSystem.

This class allows using virtual wxFSFiles with any wx functions taking
streams. E.g. it makes it possible to load images and animations from
wxFileSystem.

Closes #14185.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71206 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-04-16 13:53:49 +00:00
parent f5ef4d69b7
commit b7775a521f
4 changed files with 76 additions and 0 deletions

View File

@@ -756,5 +756,29 @@ class wxFileSystemModule : public wxModule
IMPLEMENT_DYNAMIC_CLASS(wxFileSystemModule, wxModule)
//// wxFSInputStream
wxFSInputStream::wxFSInputStream(const wxString& filename, int flags)
{
wxFileSystem fs;
m_file = fs.OpenFile(filename, flags | wxFS_READ);
if ( m_file )
{
wxInputStream* const stream = m_file->GetStream();
if ( stream )
{
// Notice that we pass the stream by reference: it shouldn't be
// deleted by us as it's owned by m_file already.
InitParentStream(*stream);
}
}
}
wxFSInputStream::~wxFSInputStream()
{
delete m_file;
}
#endif
// wxUSE_FILESYSTEM