]> git.saurik.com Git - wxWidgets.git/blame - src/common/fs_filter.cpp
Use C locale representation for floating point numbers in wxAny.
[wxWidgets.git] / src / common / fs_filter.cpp
CommitLineData
37671b82 1/////////////////////////////////////////////////////////////////////////////
8aa3cd14 2// Name: src/common/fs_filter.cpp
37671b82
MW
3// Purpose: wxFilter file system handler
4// Author: Mike Wetherell
5// Copyright: (c) 2006 Mike Wetherell
6// CVS-ID: $Id$
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#include "wx/wxprec.h"
11
12#ifdef __BORLANDC__
8aa3cd14 13 #pragma hdrstop
37671b82
MW
14#endif
15
16#if wxUSE_FILESYSTEM
17
18#include "wx/fs_filter.h"
19
b4f4d3dd 20#ifndef WX_PRECOMP
37671b82
MW
21#endif
22
664e1314 23#include "wx/scopedptr.h"
37671b82
MW
24
25wxDEFINE_SCOPED_PTR_TYPE(wxFSFile)
26wxDEFINE_SCOPED_PTR_TYPE(wxInputStream)
27
28//----------------------------------------------------------------------------
29// wxFilterFSHandler
30//----------------------------------------------------------------------------
31
32bool wxFilterFSHandler::CanOpen(const wxString& location)
33{
34 return wxFilterClassFactory::Find(GetProtocol(location)) != NULL;
35}
36
37wxFSFile* wxFilterFSHandler::OpenFile(
38 wxFileSystem& fs,
39 const wxString& location)
40{
41 wxString right = GetRightLocation(location);
42 if (!right.empty())
43 return NULL;
8aa3cd14 44
37671b82
MW
45 wxString protocol = GetProtocol(location);
46 const wxFilterClassFactory *factory = wxFilterClassFactory::Find(protocol);
47 if (!factory)
48 return NULL;
49
50 wxString left = GetLeftLocation(location);
51 wxFSFilePtr leftFile(fs.OpenFile(left));
52 if (!leftFile.get())
53 return NULL;
54
55 wxInputStreamPtr leftStream(leftFile->DetachStream());
56 if (!leftStream.get() || !leftStream->IsOk())
57 return NULL;
58
34eeb223 59 wxInputStreamPtr stream(factory->NewStream(leftStream.release()));
37671b82
MW
60
61 // The way compressed streams are supposed to be served is e.g.:
8aa3cd14
WS
62 // Content-type: application/postscript
63 // Content-encoding: gzip
37671b82
MW
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));
71
72 return new wxFSFile(stream.release(),
73 left + wxT("#") + protocol + wxT(":") + right,
74 mime,
75 GetAnchor(location)
76#if wxUSE_DATETIME
77 , leftFile->GetModificationTime()
78#endif // wxUSE_DATETIME
79 );
80}
81
8aa3cd14 82wxString wxFilterFSHandler::FindFirst(const wxString& WXUNUSED(spec), int WXUNUSED(flags))
37671b82
MW
83{
84 return wxEmptyString;
85}
86
87wxString wxFilterFSHandler::FindNext()
88{
89 return wxEmptyString;
90}
91
92#endif //wxUSE_FILESYSTEM