Ejemplo n.º 1
0
bool wxCurlFTP::Put(wxInputStream& buffer, const wxString& szRemoteFile /*= wxEmptyString*/)
{
	curl_off_t iSize = 0;

	if(m_pCURL && buffer.IsOk())
	{
		SetCurlHandleToDefaults(szRemoteFile);

		iSize = buffer.GetSize();

		if(iSize == (~(ssize_t)0))
			return false;

		SetOpt(CURLOPT_UPLOAD, TRUE);
		SetStreamReadFunction(buffer);
		SetOpt(CURLOPT_INFILESIZE_LARGE, iSize);

		if(Perform())
		{
			return ((m_iResponseCode > 199) && (m_iResponseCode < 300));
		}
	}

	return false;
}
Ejemplo n.º 2
0
bool wxCurlHTTP::Put(wxInputStream& buffer, const wxString& szRemoteFile /*= wxEmptyString*/)
{
    curl_off_t iSize = 0;

    if(m_pCURL && buffer.IsOk())
    {
        SetCurlHandleToDefaults(szRemoteFile);

        iSize = buffer.GetSize();

        if(iSize == (~(size_t)0))	// wxCurlHTTP does not know how to upload unknown length streams.
            return false;

        SetOpt(CURLOPT_UPLOAD, TRUE);
        SetOpt(CURLOPT_PUT, TRUE);
        SetStreamReadFunction(buffer);
        SetOpt(CURLOPT_INFILESIZE_LARGE, (curl_off_t)iSize);
        SetStringWriteFunction(m_szResponseBody);

        if(Perform())
        {
            return IsResponseOk();
        }
    }

    return false;
}
Ejemplo n.º 3
0
 size_t GetSize() const
     { wxASSERT(m_pStream); return m_pStream->GetSize(); }
Ejemplo n.º 4
0
// read callstacks
void Database::loadProcList(wxInputStream &file,bool collapseKernelCalls)
{
    wxTextInputStream str(file);

    wxProgressDialog progressdlg("Sleepy", "Please wait while the profile database is scanned...",
                                 (int)file.GetSize(), theMainWin,
                                 wxPD_APP_MODAL|wxPD_AUTO_HIDE);

    class CallStackPtrComp
    {
        CallStack *p;
    public:
        CallStackPtrComp(CallStack *_p): p(_p) {}
        bool operator <(const CallStackPtrComp b) const {
            return p->stack < b.p->stack;
        }
        CallStack *Get() {
            return p;
        }
    };

    std::set<CallStackPtrComp> callstackSet;

    while(!file.Eof())
    {
        wxString line = str.ReadLine();
        if (line.IsEmpty())
            break;

        std::wistringstream stream(line.c_str().AsWChar());

        CallStack callstack;
        stream >> callstack.samplecount;

        while(true)
        {
            std::wstring id;
            stream >> id;
            if (id.empty())
                break;

            const Symbol *sym = symbols[id];

            if(collapseKernelCalls && sym->isCollapseFunction) {
                callstack.stack.clear();
            }

            callstack.stack.push_back(sym);
        }

        if(collapseKernelCalls) {
            if(callstack.stack.size() && callstack.stack[0]->isCollapseModule) {
                while(callstack.stack.size() >= 2) {
                    if(	!callstack.stack[1]->isCollapseModule )
                    {
                        break;
                    }
                    callstack.stack.erase(callstack.stack.begin());
                }
            }
        }

        std::set<CallStackPtrComp>::iterator iter = callstackSet.find(&callstack);
        if(iter != callstackSet.end()) {
            ((CallStackPtrComp)*iter).Get()->samplecount += callstack.samplecount;
            continue;
        }
        callstacks.push_back(callstack);
        callstackSet.insert(&callstacks[callstacks.size()-1]);

        wxFileOffset offset = file.TellI();
        if(offset != wxInvalidOffset)
            progressdlg.Update(offset);
    }
}