22#include " fnFsHTTP.h"
33
44#include < ctime>
5+ #include < iostream>
6+ #include < iomanip>
7+ #include < sstream>
58
69#include " compat_string.h"
710
@@ -143,7 +146,7 @@ FileHandler *FileSystemHTTP::cache_file(const char *path)
143146 bool cancel = false ;
144147
145148 // Process all response chunks
146- Debug_println (" Reading HTTP data" );
149+ Debug_println (" Retrieving HTTP data" );
147150 while ( !_http->is_transaction_done () || _http->available () > 0 )
148151 {
149152 int available = _http->available ();
@@ -214,6 +217,7 @@ FileHandler *FileSystemHTTP::cache_file(const char *path)
214217 }
215218
216219 // copy from memory to SD file
220+ Debug_println (" Copy memory file to SD file" );
217221 size_t count = 0 ;
218222 fh->seek (0 , SEEK_SET);
219223 do
@@ -225,6 +229,7 @@ FileHandler *FileSystemHTTP::cache_file(const char *path)
225229 // switch to file on SD
226230 fh = fh_sd;
227231 use_memfile = false ;
232+ Debug_println (" Copy completed" );
228233 }
229234
230235 // next batch
@@ -233,6 +238,7 @@ FileHandler *FileSystemHTTP::cache_file(const char *path)
233238 tmout_counter = 1 + HTTP_GET_TIMEOUT / 50 ; // reset timeout counter
234239 }
235240 }
241+ Debug_println (" HTTP data retrieved" );
236242 _http->close ();
237243
238244 if (cancel)
@@ -384,6 +390,7 @@ bool FileSystemHTTP::dir_open(const char *path, const char *pattern, uint16_t d
384390 // Parsed entries to dircache
385391 fsdir_entry *fs_de;
386392 std::vector<IndexParser::IndexEntry>::iterator dirEntryCursor = _parser.rewind ();
393+ struct tm tm;
387394 while (dirEntryCursor != _parser.entries .end ())
388395 {
389396 // new dir entry
@@ -395,9 +402,13 @@ bool FileSystemHTTP::dir_open(const char *path, const char *pattern, uint16_t d
395402 fs_de->size = (uint32_t )atoi (dirEntryCursor->fileSize .c_str ());
396403 // attempt to get file modification time
397404 fs_de->modified_time = 0 ;
398- struct tm tm;
399405 memset (&tm, 0 , sizeof (struct tm ));
400- if (strptime (dirEntryCursor->mTime .c_str (), " %d-%b-%Y %H:%M" , &tm) != nullptr )
406+ // strptime is not available on Windows ... grh
407+ // if (strptime(dirEntryCursor->mTime.c_str(), "%d-%b-%Y %H:%M", &tm) != nullptr)
408+ // use std::get_time instead
409+ std::istringstream ss (dirEntryCursor->mTime );
410+ ss >> std::get_time (&tm, " %d-%b-%Y %H:%M" );
411+ if (!ss.fail ())
401412 {
402413 tm.tm_isdst = -1 ;
403414 fs_de->modified_time = mktime (&tm);
0 commit comments