示例#1
0
文件: fs_inet.cpp 项目: Ailick/rpcs3
bool wxInternetFSHandler::CanOpen(const wxString& location)
{
#if wxUSE_URL
    wxString p = GetProtocol(location);
    if ((p == wxT("http")) || (p == wxT("ftp")))
    {
        wxURL url(p + wxT(":") + StripProtocolAnchor(location));
        return (url.GetError() == wxURL_NOERR);
    }
#endif
    return false;
}
示例#2
0
wxFSFile* wxInternetFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs),
                                        const wxString& location)
{
#if !wxUSE_URL
    return NULL;
#else
    wxString right =
        GetProtocol(location) + wxT(":") + StripProtocolAnchor(location);

    wxURL url(right);
    if (url.GetError() == wxURL_NOERR)
    {
        wxInputStream *s = url.GetInputStream();
        if (s)
        {
            wxString tmpfile =
                wxFileName::CreateTempFileName(wxT("wxhtml"));

            {   // now copy streams content to temporary file:
                wxFileOutputStream sout(tmpfile);
                s->Read(sout);
            }
            delete s;

            // Content-Type header, as defined by the RFC 2045, has the form of
            // "type/subtype" optionally followed by (multiple) "; parameter"
            // and we need just the MIME type here.
            const wxString& content = url.GetProtocol().GetContentType();
            wxString mimetype = content.BeforeFirst(';');
            mimetype.Trim();

            return new wxFSFile(new wxTemporaryFileInputStream(tmpfile),
                                right,
                                mimetype,
                                GetAnchor(location)
#if wxUSE_DATETIME
                                , wxDateTime::Now()
#endif // wxUSE_DATETIME
                        );
        }
    }

    return NULL; // incorrect URL
#endif
}
示例#3
0
文件: fs_inet.cpp 项目: Ailick/rpcs3
wxFSFile* wxInternetFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs),
                                        const wxString& location)
{
#if !wxUSE_URL
    return NULL;
#else
    wxString right =
        GetProtocol(location) + wxT(":") + StripProtocolAnchor(location);

    wxURL url(right);
    if (url.GetError() == wxURL_NOERR)
    {
        wxInputStream *s = url.GetInputStream();
        wxString content = url.GetProtocol().GetContentType();
        if (content == wxEmptyString) content = GetMimeTypeFromExt(location);
        if (s)
        {
            wxString tmpfile =
                wxFileName::CreateTempFileName(wxT("wxhtml"));

            {   // now copy streams content to temporary file:
                wxFileOutputStream sout(tmpfile);
                s->Read(sout);
            }
            delete s;

            return new wxFSFile(new wxTemporaryFileInputStream(tmpfile),
                                right,
                                content,
                                GetAnchor(location)
#if wxUSE_DATETIME
                                , wxDateTime::Now()
#endif // wxUSE_DATETIME
                        );
        }
    }

    return (wxFSFile*) NULL; // incorrect URL
#endif
}