Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/WolfireGames/overgrowth.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Internal/filesystem.cpp')
-rw-r--r--Source/Internal/filesystem.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/Source/Internal/filesystem.cpp b/Source/Internal/filesystem.cpp
index 7262efdb..72de7b25 100644
--- a/Source/Internal/filesystem.cpp
+++ b/Source/Internal/filesystem.cpp
@@ -1112,10 +1112,10 @@ void ClearCache( bool dry_run )
modids = ModLoading::Instance().GetModsSid();
#endif
modids.push_back(CoreGameModID);
- for( unsigned i = 0; i < modids.size(); i++ )
+ for(auto & modid : modids)
{
stringstream write_data_path;
- write_data_path << GetWritePath(modids[i]);
+ write_data_path << GetWritePath(modid);
write_data_path << "Data/";
vector<string> write_dir_files;
@@ -1185,16 +1185,12 @@ void ClearCache( bool dry_run )
vector<string> keep_files;
vector<string> remove_files;
- for( vector<string>::iterator pit = write_dir_files.begin();
- pit != write_dir_files.end();
- pit++ )
+ for(auto & write_dir_file : write_dir_files)
{
bool found = false;
- for( vector<pair<string,string> >::iterator fit = remove_with_ending.begin();
- fit != remove_with_ending.end();
- fit++ )
+ for(auto & fit : remove_with_ending)
{
- if( hasBeginning( *pit, fit->first) && hasEnding( *pit, fit->second ) )
+ if( hasBeginning( write_dir_file, fit.first) && hasEnding( write_dir_file, fit.second ) )
{
found = true;
}
@@ -1203,11 +1199,9 @@ void ClearCache( bool dry_run )
if( found )
{
/* Second pass with exclusion, if there's one match, regret inclusion, exclusion overrides */
- for( vector<pair<string,string> >::iterator fit = exclude_with_ending.begin();
- fit != exclude_with_ending.end();
- fit++ )
+ for(auto & fit : exclude_with_ending)
{
- if( hasBeginning( *pit, fit->first) && ( fit->second.empty() || hasEnding( *pit, fit->second ) ) )
+ if( hasBeginning( write_dir_file, fit.first) && ( fit.second.empty() || hasEnding( write_dir_file, fit.second ) ) )
{
found = false;
}
@@ -1216,17 +1210,17 @@ void ClearCache( bool dry_run )
if( found )
{
- remove_files.push_back( *pit );
+ remove_files.push_back( write_dir_file );
}
else
{
- keep_files.push_back( *pit );
+ keep_files.push_back( write_dir_file );
}
}
- for( unsigned int i = 0; i < remove_files.size(); i++ )
+ for(auto & remove_file : remove_files)
{
- string path = write_data_path.str() + remove_files[i];
+ string path = write_data_path.str() + remove_file;
LOGI << "Removing: " << path << endl;
if( dry_run == false )
{
@@ -1242,9 +1236,9 @@ void ClearCache( bool dry_run )
{
//Create a set with all unique folder paths
set<string> folder_paths;
- for( unsigned int i = 0; i < remove_files.size(); i++ )
+ for(auto & remove_file : remove_files)
{
- string base = SplitPathFileName( remove_files[i] ).first;
+ string base = SplitPathFileName( remove_file ).first;
while( base.empty() == false )
{
@@ -1268,9 +1262,9 @@ void ClearCache( bool dry_run )
sort(empty_folder_paths.begin(), empty_folder_paths.end(), string_sort_by_length_r );
- for( unsigned i = 0; i < empty_folder_paths.size(); i++ )
+ for(auto & empty_folder_path : empty_folder_paths)
{
- string path = write_data_path.str() + empty_folder_paths[i];
+ string path = write_data_path.str() + empty_folder_path;
LOGI << "Removing Empty Folder:" << path << endl;
if( deletefile(path.c_str()) != 0 )
{
@@ -1280,9 +1274,9 @@ void ClearCache( bool dry_run )
}
}
- for( unsigned int i = 0; i < keep_files.size(); i++ )
+ for(auto & keep_file : keep_files)
{
- string path = write_data_path.str() + keep_files[i];
+ string path = write_data_path.str() + keep_file;
LOGI << "Keeping: " << path << endl;
}
}