]>
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
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
17 #include "wx/fs_filter.h"
22 #include "wx/scopedptr.h"
24 wxDEFINE_SCOPED_PTR_TYPE(wxFSFile
)
25 wxDEFINE_SCOPED_PTR_TYPE(wxInputStream
)
27 //----------------------------------------------------------------------------
29 //----------------------------------------------------------------------------
31 bool wxFilterFSHandler::CanOpen(const wxString
& location
)
33 return wxFilterClassFactory::Find(GetProtocol(location
)) != NULL
;
36 wxFSFile
* wxFilterFSHandler::OpenFile(
38 const wxString
& location
)
40 wxString right
= GetRightLocation(location
);
44 wxString protocol
= GetProtocol(location
);
45 const wxFilterClassFactory
*factory
= wxFilterClassFactory::Find(protocol
);
49 wxString left
= GetLeftLocation(location
);
50 wxFSFilePtr
leftFile(fs
.OpenFile(left
));
54 wxInputStreamPtr
leftStream(leftFile
->DetachStream());
55 if (!leftStream
.get() || !leftStream
->IsOk())
58 wxInputStreamPtr
stream(factory
->NewStream(leftStream
.release()));
60 // The way compressed streams are supposed to be served is e.g.:
61 // Content-type: application/postscript
62 // Content-encoding: gzip
63 // So the mime type should be just the mime type of the lhs. However check
64 // whether the mime type is that of this compression format (e.g.
65 // application/gzip). If so pop any extension and try GetMimeTypeFromExt,
66 // e.g. if it were '.ps.gz' pop the '.gz' and try looking up '.ps'
67 wxString mime
= leftFile
->GetMimeType();
68 if (factory
->CanHandle(mime
, wxSTREAM_MIMETYPE
))
69 mime
= GetMimeTypeFromExt(factory
->PopExtension(left
));
71 return new wxFSFile(stream
.release(),
72 left
+ wxT("#") + protocol
+ wxT(":") + right
,
76 , leftFile
->GetModificationTime()
77 #endif // wxUSE_DATETIME
81 wxString
wxFilterFSHandler::FindFirst(const wxString
& WXUNUSED(spec
), int WXUNUSED(flags
))
86 wxString
wxFilterFSHandler::FindNext()
91 #endif //wxUSE_FILESYSTEM