Mercurial > mercurial > hgweb_rsearcher.cgi
diff src/net.cpp @ 10:36811fd22bd2
v1.4
author | pyon@macmini |
---|---|
date | Thu, 08 Nov 2018 19:15:43 +0900 |
parents | ae89ce4793d8 |
children | 799b6008db8e |
line wrap: on
line diff
--- a/src/net.cpp Wed Oct 31 20:10:29 2018 +0900 +++ b/src/net.cpp Thu Nov 08 19:15:43 2018 +0900 @@ -1,5 +1,5 @@ // Filename : net.cpp -// Last Change: 2018-10-31 水 10:42:06. +// Last Change: 2018-11-08 木 10:08:45. // #include <wx/datetime.h> @@ -103,3 +103,35 @@ get.Close(); } +void RsHttp::GetImages2Memory( wxString hhs, wxString date ) +{ + wxHTTP get; + get.SetTimeout( 30 ); + get.SetFlags( wxSOCKET_WAITALL|wxSOCKET_BLOCK ); + while ( !get.Connect( m_server, m_port ) ) + wxSleep( 1 ); + + wxString url = wxT( "/images/" ) + date + wxT( "/" ) + hhs + wxT( ".tgz" ); + + wxInputStream *http_istream = get.GetInputStream( url ); + if ( get.GetError() == wxPROTO_NOERR ) { + //int size = http_istream->GetSize(); + wxZlibInputStream zlib_istream( http_istream ); // 0: no cache : bad + + wxTarEntry* entry; + wxTarInputStream tar_istream( zlib_istream ); + int i = 1; + while ( ( entry = tar_istream.GetNextEntry() ) != NULL ) { + //wxString name = entry->GetName(); + wxFileOutputStream file_ostream( wxString::Format( wxT( ".cache/%s_%d" ), date, i++ ) ); + file_ostream.Write( tar_istream ); + file_ostream.Close(); + } + } else { + wxMessageBox( wxT( "Re:Searcher Error: get err" ) ); + } + + //wxDELETE( http_istream ); + get.Close(); +} +