181 const std::string &dev,
182 const std::string &ext,
188 bool isdir = mx::ioutils::dir_exists_is( dir, errc );
190 mx_error_check_code( errc );
194 return mx::error_report<verboseT>( mx::error_t::dirnotfound, dir +
" does not exist" );
199 mx_error_check_code( errc );
204 mx_error_check_code( errc );
209 bool prevLogFound =
false;
211 size_t prevLogFile_n = 0;
214 bool follLogFound =
false;
216 size_t follLogFile_n;
218 std::string basedir = dir +
'/' + dev +
'/';
221 mx_error_check_code( errc );
225 while( prevLogFound ==
false && ndays < m_searchDaySpan )
229 std::vector<std::string> tmp_flist;
231 isdir = mx::ioutils::dir_exists_is( basedir + subdir.
path(), errc );
232 mx_error_check_code( errc );
236 mx_error_check( subdir.
subDay() );
240 mx_error_check( mx::ioutils::getFileNames( tmp_flist, basedir + subdir.
path(), dev,
"", ext ) );
242 if( tmp_flist.size() == 0 )
244 mx_error_check( subdir.
subDay() );
249 for(
size_t n = tmp_flist.size() - 1; n !=
static_cast<size_t>( -1 ); --n )
256 #ifdef XWCTEST_LOGMAP_LATFM_BADALL1
265 std::throw_with_nested(
xwcException(
"parsing filename" ) );
276 prevLogSubDir = subdir;
279 std::cerr <<
"found previous log: " << tmp_flist[n] <<
'\n';
286 mx_error_check( subdir.
subDay() );
292 return mx::error_t::noerror;
295 subdir = lastFile.
subDir( &errc );
296 mx_error_check_code( errc );
300 while( follLogFound ==
false && ndays < m_searchDaySpan )
305 #ifdef XWCTEST_LOGMAP_LATFM_BADALL2
312 std::vector<std::string> tmp_flist;
314 isdir = mx::ioutils::dir_exists_is( basedir + subdir.
path(), errc );
316 if( errc != mx::error_t::noerror )
318 return mx::error_report<verboseT>( errc,
"error from std::filesystem" );
323 mx_error_check( subdir.
addDay() );
327 mx_error_check( mx::ioutils::getFileNames( tmp_flist, basedir + subdir.
path(), dev,
"", ext ) );
329 if( tmp_flist.size() == 0 )
331 mx_error_check( subdir.
addDay() );
336 for(
size_t n = 0; n < tmp_flist.size(); ++n )
350 follLogSubDir = subdir;
359 mx_error_check( subdir.
addDay() );
364 std::throw_with_nested(
xwcException(
"parsing filename" ) );
371 follLogSubDir = lastFile.
subDir( &errc );
372 mx_error_check_code( errc );
376 bool exists = mx::ioutils::dir_exists_is(basedir + follLogSubDir.
path(), errc);
379 while(!exists && n < m_searchDaySpan)
385 exists = mx::ioutils::dir_exists_is(basedir + follLogSubDir.
path(), errc);
389 follLogFile_n =
static_cast<size_t>( -1 );
392 if( prevLogSubDir == follLogSubDir )
398 #ifdef XWCTEST_LOGMAP_LATFM_BADALL3
403 subdir = prevLogSubDir;
405 std::vector<std::string> tmp_flist;
407 mx_error_check( mx::ioutils::getFileNames( tmp_flist, basedir + subdir.
path(), dev,
"", ext ) );
409 if( follLogFile_n ==
static_cast<size_t>( -1 ) )
411 follLogFile_n = tmp_flist.size();
416 if( follLogFile_n > tmp_flist.size() )
418 return mx::error_report<verboseT>( mx::error_t::sizeerr,
419 "miscounted the number of files somewhere" );
423 mx_error_check( addFileListToFileMap( dev, tmp_flist, prevLogFile_n, follLogFile_n ) );
427 std::throw_with_nested(
xwcException(
"adding file list to map" ) );
432 std::cerr <<
"prevLogSubDir != follLogSubDir\n";
436 #ifdef XWCTEST_LOGMAP_LATFM_XWCE4
440 #ifdef XWCTEST_LOGMAP_LATFM_BADALL4
445 subdir = prevLogSubDir;
447 std::vector<std::string> tmp_flist;
449 mx_error_check( mx::ioutils::getFileNames( tmp_flist, basedir + subdir.
path(), dev,
"", ext ) );
451 mx_error_check( addFileListToFileMap( dev, tmp_flist, prevLogFile_n, tmp_flist.size() ) );
455 std::throw_with_nested(
xwcException(
"adding file list to map" ) );
458 mx_error_check( subdir.
addDay() );
460 while( subdir < follLogSubDir )
465 #ifdef XWCTEST_LOGMAP_LATFM_XWCE5
469 #ifdef XWCTEST_LOGMAP_LATFM_BADALL5
474 if( !std::filesystem::exists( basedir + subdir.
path() ) )
476 mx_error_check( subdir.
addDay() );
480 std::vector<std::string> tmp_flist;
482 mx_error_check( mx::ioutils::getFileNames( tmp_flist, basedir + subdir.
path(), dev,
"", ext ) );
484 mx_error_check( addFileListToFileMap( dev, tmp_flist, 0, tmp_flist.size() ) );
486 mx_error_check( subdir.
addDay() );
490 std::throw_with_nested(
xwcException(
"adding file list to map" ) );
497 #ifdef XWCTEST_LOGMAP_LATFM_XWCE6
501 #ifdef XWCTEST_LOGMAP_LATFM_BADALL6
506 std::vector<std::string> tmp_flist;
514 mx_error_check( mx::ioutils::getFileNames( tmp_flist, basedir + subdir.
path(), dev,
"", ext ) );
517 if(errc == mx::error_t::noerror)
520 if( follLogFile_n ==
static_cast<size_t>( -1 ) )
522 follLogFile_n = tmp_flist.size();
527 if( follLogFile_n > tmp_flist.size() )
529 return mx::error_report<verboseT>( mx::error_t::sizeerr,
530 "miscounted the number of files somewhere" );
534 mx_error_check( addFileListToFileMap( dev, tmp_flist, 0, follLogFile_n ) );
539 std::throw_with_nested(
xwcException(
"adding file list to map" ) );
543 return mx::error_t::noerror;
720 if( m_appToFileMap[appName].size() == 0 )
722 std::cerr <<
"*************************************\n\n";
723 std::cerr <<
"No files for " << appName <<
"\n";
724 std::cerr <<
"*************************************\n\n";
729 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
733 if( m_appToBufferMap[appName].m_memory.size() > 0 )
735 if( m_appToBufferMap[appName].m_startTime <= startTime && m_appToBufferMap[appName].m_endTime >= startTime )
737 std::cerr <<
"good!\n";
742 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
745 if( m_appToBufferMap[appName].m_startTime > startTime )
748 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
751 auto last = m_appToFileMap[appName].begin();
752 while( last->timestamp() < m_appToBufferMap[appName].m_startTime )
755 if( last == m_appToFileMap[appName].end() )
761 while( first->timestamp() > startTime )
764 if( first == m_appToFileMap[appName].begin() )
769 std::cerr <<
"open earlier files!\n";
772 for(
auto it = last; it != first; --it )
774 m_appToBufferMap[appName].loadFile( *it );
781 auto first = m_appToFileMap[appName].end();
784 while( first->timestamp() > m_appToBufferMap[appName].m_endTime )
787 if( first == m_appToFileMap[appName].begin() )
792 while( last->timestamp() < startTime )
795 if( last == m_appToFileMap[appName].end() )
800 std::cerr <<
"open later file for " << appName <<
"!\n";
801 for(
auto it = first; it != last; ++it )
803 m_appToBufferMap[appName].loadFile( *it );
810 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
813 auto before = m_appToFileMap[appName].begin();
815 for( ; before != m_appToFileMap[appName].end(); ++before )
817 if( !( before->timestamp() < startTime ) )
824 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
827 if( before == m_appToFileMap[appName].begin() )
829 std::cerr <<
"No files in range for " << appName <<
"\n";
834 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
837 m_appToBufferMap.emplace( std::pair<std::string, logInMemory>( appName,
logInMemory() ) );
840 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";
843 m_appToBufferMap[appName].loadFile( *before );
844 if( ++before != m_appToFileMap[appName].end() )
846 m_appToBufferMap[appName].loadFile( *before );
850 std::cerr << __FILE__ <<
" " << __LINE__ <<
"\n";