Mercurial > mercurial > hgweb_rsearcher.cgi
comparison src/net.cpp @ 10:36811fd22bd2
v1.4
author | pyon@macmini |
---|---|
date | Thu, 08 Nov 2018 19:15:43 +0900 |
parents | ae89ce4793d8 |
children | 799b6008db8e |
comparison
equal
deleted
inserted
replaced
9:ae89ce4793d8 | 10:36811fd22bd2 |
---|---|
1 // Filename : net.cpp | 1 // Filename : net.cpp |
2 // Last Change: 2018-10-31 水 10:42:06. | 2 // Last Change: 2018-11-08 木 10:08:45. |
3 // | 3 // |
4 | 4 |
5 #include <wx/datetime.h> | 5 #include <wx/datetime.h> |
6 #include <wx/stream.h> | 6 #include <wx/stream.h> |
7 #include <wx/zstream.h> | 7 #include <wx/zstream.h> |
101 | 101 |
102 //wxDELETE( http_istream ); | 102 //wxDELETE( http_istream ); |
103 get.Close(); | 103 get.Close(); |
104 } | 104 } |
105 | 105 |
106 void RsHttp::GetImages2Memory( wxString hhs, wxString date ) | |
107 { | |
108 wxHTTP get; | |
109 get.SetTimeout( 30 ); | |
110 get.SetFlags( wxSOCKET_WAITALL|wxSOCKET_BLOCK ); | |
111 while ( !get.Connect( m_server, m_port ) ) | |
112 wxSleep( 1 ); | |
113 | |
114 wxString url = wxT( "/images/" ) + date + wxT( "/" ) + hhs + wxT( ".tgz" ); | |
115 | |
116 wxInputStream *http_istream = get.GetInputStream( url ); | |
117 if ( get.GetError() == wxPROTO_NOERR ) { | |
118 //int size = http_istream->GetSize(); | |
119 wxZlibInputStream zlib_istream( http_istream ); // 0: no cache : bad | |
120 | |
121 wxTarEntry* entry; | |
122 wxTarInputStream tar_istream( zlib_istream ); | |
123 int i = 1; | |
124 while ( ( entry = tar_istream.GetNextEntry() ) != NULL ) { | |
125 //wxString name = entry->GetName(); | |
126 wxFileOutputStream file_ostream( wxString::Format( wxT( ".cache/%s_%d" ), date, i++ ) ); | |
127 file_ostream.Write( tar_istream ); | |
128 file_ostream.Close(); | |
129 } | |
130 } else { | |
131 wxMessageBox( wxT( "Re:Searcher Error: get err" ) ); | |
132 } | |
133 | |
134 //wxDELETE( http_istream ); | |
135 get.Close(); | |
136 } | |
137 |