1 /////////////////////////////////////////////////////////////////////////////
2 // Name: ext/filesys/cpp/fshandler.h
3 // Purpose: C++ classes for Wx::PlFSFile and Wx::PlFileSystemHandler
4 // Author: Mattia Barbon
7 // RCS-ID: $Id: fshandler.h 2057 2007-06-18 23:03:00Z mbarbon $
8 // Copyright: (c) 2002, 2004 Mattia Barbon
9 // Licence: This program is free software; you can redistribute it and/or
10 // modify it under the same terms as Perl itself
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WXPERL_FS_FSHANDLER_H
14 #define _WXPERL_FS_FSHANDLER_H
16 #include <wx/filesys.h>
17 #include "cpp/streams.h"
18 #include "cpp/v_cback.h"
20 class wxPlFSFile:public wxFSFile
23 wxPlFSFile( SV* fh, const wxString& loc, const wxString& mimetype,
24 const wxString& anchor )
25 : wxFSFile( wxPliInputStream_ctor( fh ),
26 loc, mimetype, anchor, wxDateTime() ) { }
29 class wxPlFileSystemHandler:public wxFileSystemHandler
31 WXPLI_DECLARE_DYNAMIC_CLASS( wxPlFileSystemHandler );
32 WXPLI_DECLARE_V_CBACK();
34 wxPlFileSystemHandler( const char* package )
35 : m_callback( "Wx::PlFileSystemHandler" )
37 m_callback.SetSelf( wxPli_make_object( this, package ), true );
40 DEC_V_CBACK_BOOL__WXSTRING( CanOpen );
41 DEC_V_CBACK_WXSTRING__WXSTRING_INT( FindFirst );
42 DEC_V_CBACK_WXSTRING__VOID( FindNext );
43 DEC_V_CBACK_WXFSFILEP__WXFILESYSTEM_WXSTRING( OpenFile );
46 WXPLI_IMPLEMENT_DYNAMIC_CLASS( wxPlFileSystemHandler, wxFileSystemHandler );
48 DEF_V_CBACK_WXSTRING__VOID_pure( wxPlFileSystemHandler, wxFileSystemHandler,
50 DEF_V_CBACK_BOOL__WXSTRING_pure( wxPlFileSystemHandler, wxFileSystemHandler,
53 wxString wxPlFileSystemHandler::FindFirst( const wxString& file, int flags )
56 if( wxPliVirtualCallback_FindCallback( aTHX_ &m_callback, "FindFirst" ) )
58 SV* ret = wxPliVirtualCallback_CallCallback( aTHX_ &m_callback,
62 WXSTRING_INPUT( val, wxString, ret );
69 #include <wx/wfstream.h>
71 wxFSFile* wxPlFileSystemHandler::OpenFile( wxFileSystem& parent,
72 const wxString& name )
75 if( wxPliVirtualCallback_FindCallback( aTHX_ &m_callback, "OpenFile" ) )
77 SV* fs = wxPli_object_2_sv( aTHX_ sv_newmortal(), &parent );
78 SV* ret = wxPliVirtualCallback_CallCallback( aTHX_ &m_callback,
81 wxFSFile* val = (wxFSFile*)wxPli_sv_2_object( aTHX_ ret,
83 sv_setiv( SvRV( fs ), 0 );
85 sv_setiv( SvRV( ret ), 0 );