]>
git.saurik.com Git - wxWidgets.git/blob - src/common/fs_filter.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/fs_filter.cpp
3 // Purpose: wxFilter file system handler
4 // Author: Mike Wetherell
5 // Copyright: (c) 2006 Mike Wetherell
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #include "wx/wxprec.h"
18 #include "wx/fs_filter.h"
23 #include "wx/ptr_scpd.h"
25 wxDEFINE_SCOPED_PTR_TYPE(wxFSFile
)
26 wxDEFINE_SCOPED_PTR_TYPE(wxInputStream
)
28 //----------------------------------------------------------------------------
30 //----------------------------------------------------------------------------
32 bool wxFilterFSHandler::CanOpen(const wxString
& location
)
34 return wxFilterClassFactory::Find(GetProtocol(location
)) != NULL
;
37 wxFSFile
* wxFilterFSHandler::OpenFile(
39 const wxString
& location
)
41 wxString right
= GetRightLocation(location
);
45 wxString protocol
= GetProtocol(location
);
46 const wxFilterClassFactory
*factory
= wxFilterClassFactory::Find(protocol
);
50 wxString left
= GetLeftLocation(location
);
51 wxFSFilePtr
leftFile(fs
.OpenFile(left
));
55 wxInputStreamPtr
leftStream(leftFile
->DetachStream());
56 if (!leftStream
.get() || !leftStream
->IsOk())
59 wxInputStreamPtr
stream(factory
->NewStream(leftStream
.release()));
61 // The way compressed streams are supposed to be served is e.g.:
62 // Content-type: application/postscript
63 // Content-encoding: gzip
64 // So the mime type should be just the mime type of the lhs. However check
65 // whether the mime type is that of this compression format (e.g.
66 // application/gzip). If so pop any extension and try GetMimeTypeFromExt,
67 // e.g. if it were '.ps.gz' pop the '.gz' and try looking up '.ps'
68 wxString mime
= leftFile
->GetMimeType();
69 if (factory
->CanHandle(mime
, wxSTREAM_MIMETYPE
))
70 mime
= GetMimeTypeFromExt(factory
->PopExtension(left
));
72 return new wxFSFile(stream
.release(),
73 left
+ wxT("#") + protocol
+ wxT(":") + right
,
77 , leftFile
->GetModificationTime()
78 #endif // wxUSE_DATETIME
82 wxString
wxFilterFSHandler::FindFirst(const wxString
& WXUNUSED(spec
), int WXUNUSED(flags
))
87 wxString
wxFilterFSHandler::FindNext()
92 #endif //wxUSE_FILESYSTEM