175 const std::string &dev,
176 const std::string &ext,
182 bool isdir = mx::ioutils::dir_exists_is( dir, errc );
184 mx_error_check_code( errc );
188 return mx::error_report<verboseT>( mx::error_t::dirnotfound, dir +
" does not exist" );
193 mx_error_check_code( errc );
198 mx_error_check_code( errc );
203 bool prevLogFound =
false;
205 size_t prevLogFile_n = 0;
208 bool follLogFound =
false;
210 size_t follLogFile_n;
212 std::string basedir = dir +
'/' + dev +
'/';
215 mx_error_check_code( errc );
219 while( prevLogFound ==
false && ndays < 5 )
223 std::vector<std::string> tmp_flist;
225 isdir = mx::ioutils::dir_exists_is( basedir + subdir.
path(), errc );
226 mx_error_check_code( errc );
230 mx_error_check( subdir.
subDay() );
234 mx_error_check( mx::ioutils::getFileNames( tmp_flist, basedir + subdir.
path(), dev,
"", ext ) );
236 if( tmp_flist.size() == 0 )
238 mx_error_check( subdir.
subDay() );
243 for(
size_t n = tmp_flist.size() - 1; n !=
static_cast<size_t>( -1 ); --n )
250 #ifdef XWCTEST_LOGMAP_LATFM_BADALL1
259 std::throw_with_nested(
xwcException(
"parsing filename" ) );
270 prevLogSubDir = subdir;
278 mx_error_check( subdir.
subDay() );
284 return mx::error_t::noerror;
287 subdir = lastFile.
subDir( &errc );
288 mx_error_check_code( errc );
292 while( follLogFound ==
false && ndays < 5 )
297 #ifdef XWCTEST_LOGMAP_LATFM_BADALL2
304 std::vector<std::string> tmp_flist;
306 isdir = mx::ioutils::dir_exists_is( basedir + subdir.
path(), errc );
308 if( errc != mx::error_t::noerror )
310 return mx::error_report<verboseT>( errc,
"error from std::filesystem" );
315 mx_error_check( subdir.
addDay() );
319 mx_error_check( mx::ioutils::getFileNames( tmp_flist, basedir + subdir.
path(), dev,
"", ext ) );
321 if( tmp_flist.size() == 0 )
323 mx_error_check( subdir.
addDay() );
328 for(
size_t n = 0; n < tmp_flist.size(); ++n )
342 follLogSubDir = subdir;
351 mx_error_check( subdir.
addDay() );
356 std::throw_with_nested(
xwcException(
"parsing filename" ) );
363 follLogSubDir = lastFile.
subDir( &errc );
364 mx_error_check_code( errc );
366 follLogFile_n =
static_cast<size_t>( -1 );
369 if( prevLogSubDir == follLogSubDir )
373 #ifdef XWCTEST_LOGMAP_LATFM_BADALL3
378 subdir = prevLogSubDir;
380 std::vector<std::string> tmp_flist;
382 mx_error_check( mx::ioutils::getFileNames( tmp_flist, basedir + subdir.
path(), dev,
"", ext ) );
384 if( follLogFile_n ==
static_cast<size_t>( -1 ) )
386 follLogFile_n = tmp_flist.size();
391 if( follLogFile_n > tmp_flist.size() )
393 return mx::error_report<verboseT>( mx::error_t::sizeerr,
394 "miscounted the number of files somewhere" );
398 mx_error_check( addFileListToFileMap( dev, tmp_flist, prevLogFile_n, follLogFile_n ) );
402 std::throw_with_nested(
xwcException(
"adding file list to map" ) );
410 #ifdef XWCTEST_LOGMAP_LATFM_XWCE4
414 #ifdef XWCTEST_LOGMAP_LATFM_BADALL4
419 subdir = prevLogSubDir;
421 std::vector<std::string> tmp_flist;
423 mx_error_check( mx::ioutils::getFileNames( tmp_flist, basedir + subdir.
path(), dev,
"", ext ) );
425 mx_error_check( addFileListToFileMap( dev, tmp_flist, prevLogFile_n, tmp_flist.size() ) );
429 std::throw_with_nested(
xwcException(
"adding file list to map" ) );
432 mx_error_check( subdir.
addDay() );
434 while( subdir < follLogSubDir )
439 #ifdef XWCTEST_LOGMAP_LATFM_XWCE5
443 #ifdef XWCTEST_LOGMAP_LATFM_BADALL5
448 if( !std::filesystem::exists( basedir + subdir.
path() ) )
450 mx_error_check( subdir.
addDay() );
454 std::vector<std::string> tmp_flist;
456 mx_error_check( mx::ioutils::getFileNames( tmp_flist, basedir + subdir.
path(), dev,
"", ext ) );
458 mx_error_check( addFileListToFileMap( dev, tmp_flist, 0, tmp_flist.size() ) );
460 mx_error_check( subdir.
addDay() );
464 std::throw_with_nested(
xwcException(
"adding file list to map" ) );
471 #ifdef XWCTEST_LOGMAP_LATFM_XWCE6
475 #ifdef XWCTEST_LOGMAP_LATFM_BADALL6
480 std::vector<std::string> tmp_flist;
482 mx_error_check( mx::ioutils::getFileNames( tmp_flist, basedir + subdir.
path(), dev,
"", ext ) );
484 if( follLogFile_n ==
static_cast<size_t>( -1 ) )
486 follLogFile_n = tmp_flist.size();
491 if( follLogFile_n > tmp_flist.size() )
493 return mx::error_report<verboseT>( mx::error_t::sizeerr,
494 "miscounted the number of files somewhere" );
498 mx_error_check( addFileListToFileMap( dev, tmp_flist, 0, follLogFile_n ) );
502 std::throw_with_nested(
xwcException(
"adding file list to map" ) );
506 return mx::error_t::noerror;
684 if( m_appToFileMap[appName].size() == 0 )
686 std::cerr <<
"*************************************\n\n";
687 std::cerr <<
"No files for " << appName <<
"\n";
688 std::cerr <<
"*************************************\n\n";
693 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
697 if( m_appToBufferMap[appName].m_memory.size() > 0 )
699 if( m_appToBufferMap[appName].m_startTime <= startTime && m_appToBufferMap[appName].m_endTime >= startTime )
701 std::cerr <<
"good!\n";
706 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
709 if( m_appToBufferMap[appName].m_startTime > startTime )
712 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
715 auto last = m_appToFileMap[appName].begin();
716 while( last->timestamp() < m_appToBufferMap[appName].m_startTime )
719 if( last == m_appToFileMap[appName].end() )
725 while( first->timestamp() > startTime )
728 if( first == m_appToFileMap[appName].begin() )
733 std::cerr <<
"open earlier files!\n";
736 for(
auto it = last; it != first; --it )
738 m_appToBufferMap[appName].loadFile( *it );
745 auto first = m_appToFileMap[appName].end();
748 while( first->timestamp() > m_appToBufferMap[appName].m_endTime )
751 if( first == m_appToFileMap[appName].begin() )
756 while( last->timestamp() < startTime )
759 if( last == m_appToFileMap[appName].end() )
764 std::cerr <<
"open later file for " << appName <<
"!\n";
765 for(
auto it = first; it != last; ++it )
767 m_appToBufferMap[appName].loadFile( *it );
774 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
777 auto before = m_appToFileMap[appName].begin();
779 for( ; before != m_appToFileMap[appName].end(); ++before )
781 if( !( before->timestamp() < startTime ) )
788 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
791 if( before == m_appToFileMap[appName].begin() )
793 std::cerr <<
"No files in range for " << appName <<
"\n";
798 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
801 m_appToBufferMap.emplace( std::pair<std::string, logInMemory>( appName,
logInMemory() ) );
804 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
807 m_appToBufferMap[appName].loadFile( *before );
808 if( ++before != m_appToFileMap[appName].end() )
810 m_appToBufferMap[appName].loadFile( *before );
814 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";