content/browser/storage_partition_impl_map.cc
// Helper function for doing a depth-first deletion of the data on disk.
// Examines paths directly in |current_dir| (no recursion) and tries to
// delete from disk anything that is in, or isn't a parent of something in
// |paths_to_keep|. Paths that need further expansion are added to
// |paths_to_consider|.
Helper function for doing a depth-first deletion of the data on disk.
Examines paths directly in |current_dir| (no recursion) and tries to
delete from disk anything that is in, or isn't a parent of something in
|paths_to_keep|. Paths that need further expansion are added to
|paths_to_consider|.
Helper function for doing a depth - first deletion of the data on disk . Examines paths directly in |current_dir| ( no recursion ) and tries to delete from disk anything that is in or isn ' t a parent of something in |paths_to_keep| . Paths that need further expansion are added to |paths_to_consider| .
void ObliterateOneDirectory(const FilePath& current_dir,
                            const std::vector<FilePath>& paths_to_keep,
                            std::vector<FilePath>* paths_to_consider) {
  CHECK(current_dir.IsAbsolute());
  file_util::FileEnumerator enumerator(current_dir, false, kAllFileTypes);
  for (FilePath to_delete = enumerator.Next(); !to_delete.empty();
       to_delete = enumerator.Next()) {
    enum { kSkip, kEnqueue, kDelete } action = kDelete;
    for (std::vector<FilePath>::const_iterator to_keep = paths_to_keep.begin();
         to_keep != paths_to_keep.end();
         ++to_keep) {
      if (to_delete == *to_keep) {
        action = kSkip;
        break;
      } else if (to_delete.IsParent(*to_keep)) {
        action = kEnqueue;
        break;
      }
    }
    switch (action) {
      case kDelete:
        file_util::Delete(to_delete, true);
        break;
      case kEnqueue:
        paths_to_consider->push_back(to_delete);
        break;
      case kSkip:
        break;
    }
  }
}
void ObliterateOneDirectory ( const FilePath & current_dir , const std :: vector < FilePath > & paths_to_keep , std :: vector < FilePath > * paths_to_consider ) { CHECK ( current_dir . IsAbsolute ( ) ) ; file_util :: FileEnumerator enumerator ( current_dir , false , kAllFileTypes ) ; for ( FilePath to_delete = enumerator . Next ( ) ; ! to_delete . empty ( ) ; to_delete = enumerator . Next ( ) ) { enum { kSkip , kEnqueue , kDelete } action = kDelete ; for ( std :: vector < FilePath > :: const_iterator to_keep = paths_to_keep . begin ( ) ; to_keep != paths_to_keep . end ( ) ; ++ to_keep ) { if ( to_delete == * to_keep ) { action = kSkip ; break ; } else if ( to_delete . IsParent ( * to_keep ) ) { action = kEnqueue ; break ; } } switch ( action ) { case kDelete : file_util :: Delete ( to_delete , true ) ; break ; case kEnqueue : paths_to_consider -> push_back ( to_delete ) ; break ; case kSkip : break ; } } }
Helper function for doing a depth-first deletion of the data on disk.
Helper function for doing a depth - first deletion of the data on disk .
// Enum tracking which of the 3 possible actions to take for |to_delete|. // |to_delete| contains a path to keep. Add to stack for further // processing.