@@ -88,8 +88,8 @@ bool xrCompressor::testSKIP(LPCSTR path)
88
88
if (0 == _stricmp (p_ext, " .rc" ))
89
89
return true ;
90
90
91
- for (xr_vector<shared_str>::iterator it = exclude_exts. begin (); it != exclude_exts. end (); ++it )
92
- if (PatternMatch (p_ext, it-> c_str ()))
91
+ for (auto & it : exclude_exts)
92
+ if (PatternMatch (p_ext, it. c_str ()))
93
93
return true ;
94
94
95
95
return false ;
@@ -352,15 +352,12 @@ void xrCompressor::OpenPack(LPCSTR tgt_folder, int num)
352
352
{
353
353
CMemoryWriter W;
354
354
CInifile::Sect& S = config_ltx->r_section (" header" );
355
- auto it = S.Data .cbegin ();
356
- auto it_e = S.Data .cend ();
357
355
string4096 buff;
358
356
xr_sprintf (buff, " [%s]" , S.Name .c_str ());
359
357
W.w_string (buff);
360
- for (; it != it_e; ++it )
358
+ for (const auto & it : S. Data )
361
359
{
362
- const CInifile::Item& I = *it;
363
- xr_sprintf (buff, " %s = %s" , I.first .c_str (), I.second .c_str ());
360
+ xr_sprintf (buff, " %s = %s" , it.first .c_str (), it.second .c_str ());
364
361
W.w_string (buff);
365
362
}
366
363
W.seek (0 );
@@ -433,16 +430,15 @@ void xrCompressor::PerformWork()
433
430
int pack_num = 0 ;
434
431
OpenPack (target_name.c_str (), pack_num++);
435
432
436
- for (u32 it = 0 ; it < folders_list-> size (); it++ )
437
- write_file_header ((*folders_list)[it] , 0 , 0 , 0 , 0 );
433
+ for (auto & it : * folders_list)
434
+ write_file_header (it , 0 , 0 , 0 , 0 );
438
435
439
436
if (!bStoreFiles)
440
437
c_heap = xr_alloc<u8 >(LZO1X_999_MEM_COMPRESS);
441
438
442
439
for (u32 it = 0 ; it < files_list->size (); it++)
443
440
{
444
- xr_sprintf (
445
- caption, " Compress files: %d/%d - %d%%" , it, files_list->size (), (it * 100 ) / files_list->size ());
441
+ xr_sprintf (caption, " Compress files: %d/%d - %d%%" , it, files_list->size (), (it * 100 ) / files_list->size ());
446
442
SetWindowText (GetConsoleWindow (), caption);
447
443
printf (" \n %-80s " , (*files_list)[it]);
448
444
@@ -481,17 +477,15 @@ void xrCompressor::ProcessTargetFolder()
481
477
482
478
void xrCompressor::GatherFiles (LPCSTR path)
483
479
{
484
- xr_vector< char *>* i_list = FS.file_list_open (" $target_folder$" , path, FS_ListFiles | FS_RootOnly);
480
+ auto i_list = FS.file_list_open (" $target_folder$" , path, FS_ListFiles | FS_RootOnly);
485
481
if (!i_list)
486
482
{
487
483
Msg (" ERROR: Unable to open file list:%s" , path);
488
484
return ;
489
485
}
490
- xr_vector<char *>::iterator it = i_list->begin ();
491
- xr_vector<char *>::iterator itE = i_list->end ();
492
- for (; it != itE; ++it)
486
+ for (auto &it : *i_list)
493
487
{
494
- xr_string tmp_path = xr_string (path) + xr_string (* it);
488
+ xr_string tmp_path = xr_string (path) + xr_string (it);
495
489
if (!testSKIP (tmp_path.c_str ()))
496
490
{
497
491
files_list->push_back (xr_strdup (tmp_path.c_str ()));
@@ -510,17 +504,17 @@ bool xrCompressor::IsFolderAccepted(CInifile& ltx, LPCSTR path, BOOL& recurse)
510
504
if (ltx.section_exist (" exclude_folders" ))
511
505
{
512
506
CInifile::Sect& ef_sect = ltx.r_section (" exclude_folders" );
513
- for (auto ef_it = ef_sect.Data . cbegin (); ef_it != ef_sect. Data . cend (); ef_it++ )
507
+ for (auto &it : ef_sect.Data )
514
508
{
515
- recurse = CInifile::isBool (ef_it-> second .c_str ());
509
+ recurse = CInifile::isBool (it. second .c_str ());
516
510
if (recurse)
517
511
{
518
- if (path == strstr (path, ef_it-> first .c_str ()))
512
+ if (path == strstr (path, it. first .c_str ()))
519
513
return false ;
520
514
}
521
515
else
522
516
{
523
- if (0 == xr_strcmp (path, ef_it-> first .c_str ()))
517
+ if (0 == xr_strcmp (path, it. first .c_str ()))
524
518
return false ;
525
519
}
526
520
}
@@ -541,14 +535,13 @@ void xrCompressor::ProcessLTX(CInifile& ltx)
541
535
if (ltx.section_exist (" include_folders" ))
542
536
{
543
537
CInifile::Sect& if_sect = ltx.r_section (" include_folders" );
544
-
545
- for (auto if_it = if_sect.Data .cbegin (); if_it != if_sect.Data .cend (); ++if_it)
538
+ for (auto &it : if_sect.Data )
546
539
{
547
- BOOL ifRecurse = CInifile::isBool (if_it-> second .c_str ());
540
+ BOOL ifRecurse = CInifile::isBool (it. second .c_str ());
548
541
u32 folder_mask = FS_ListFolders | (ifRecurse ? 0 : FS_RootOnly);
549
542
550
543
string_path path;
551
- LPCSTR _path = 0 == xr_strcmp (if_it-> first .c_str (), " .\\ " ) ? " " : if_it-> first .c_str ();
544
+ LPCSTR _path = 0 == xr_strcmp (it. first .c_str (), " .\\ " ) ? " " : it. first .c_str ();
552
545
xr_strcpy (path, _path);
553
546
u32 path_len = xr_strlen (path);
554
547
if ((0 != path_len) && (path[path_len - 1 ] != ' \\ ' ))
@@ -563,18 +556,16 @@ void xrCompressor::ProcessLTX(CInifile& ltx)
563
556
if (val)
564
557
GatherFiles (path);
565
558
566
- xr_vector< char *>* i_fl_list = FS.file_list_open (" $target_folder$" , path, folder_mask);
559
+ auto i_fl_list = FS.file_list_open (" $target_folder$" , path, folder_mask);
567
560
if (!i_fl_list)
568
561
{
569
562
Msg (" ERROR: Unable to open folder list:" , path);
570
563
continue ;
571
564
}
572
565
573
- xr_vector<char *>::iterator it = i_fl_list->begin ();
574
- xr_vector<char *>::iterator itE = i_fl_list->end ();
575
- for (; it != itE; ++it)
566
+ for (auto &it : *i_fl_list)
576
567
{
577
- xr_string tmp_path = xr_string (path) + xr_string (* it);
568
+ xr_string tmp_path = xr_string (path) + xr_string (it);
578
569
bool val = IsFolderAccepted (ltx, tmp_path.c_str (), efRecurse);
579
570
if (val)
580
571
{
@@ -601,25 +592,19 @@ void xrCompressor::ProcessLTX(CInifile& ltx)
601
592
if (ltx.section_exist (" include_files" ))
602
593
{
603
594
CInifile::Sect& if_sect = ltx.r_section (" include_files" );
604
- for (auto if_it = if_sect.Data .cbegin (); if_it != if_sect.Data .cend (); ++if_it)
605
- {
606
- files_list->push_back (xr_strdup (if_it->first .c_str ()));
607
- }
595
+ for (auto &it : if_sect.Data )
596
+ files_list->push_back (xr_strdup (it.first .c_str ()));
608
597
}
609
598
610
599
PerformWork ();
611
600
612
601
// free
613
- xr_vector<char *>::iterator it = files_list->begin ();
614
- xr_vector<char *>::iterator itE = files_list->end ();
615
- for (; it != itE; ++it)
616
- xr_free (*it);
602
+ for (auto &it : *files_list)
603
+ xr_free (it);
617
604
xr_delete (files_list);
618
605
619
- it = folders_list->begin ();
620
- itE = folders_list->end ();
621
- for (; it != itE; ++it)
622
- xr_free (*it);
606
+ for (auto &it : *folders_list)
607
+ xr_free (it);
623
608
xr_delete (folders_list);
624
609
625
610
exclude_exts.clear_and_free ();
0 commit comments