CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FileSystemTraversal< T > Class Template Reference

A simple recursion engine to abstract the recursion of directories. It provides several callback hooks to instrument and control the recursion. Hooks will be called on the provided delegate object of type T. More...

#include <fs_traversal.h>

Public Types

typedef void(T::* VoidCallback )(const std::string &relative_path, const std::string &dir_name)
 
typedef bool(T::* BoolCallback )(const std::string &relative_path, const std::string &dir_name)
 

Public Member Functions

 FileSystemTraversal (T *delegate, const std::string &relative_to_directory, const bool recurse)
 
void Recurse (const std::string &dir_path) const
 

Public Attributes

VoidCallback fn_enter_dir
 
VoidCallback fn_leave_dir
 
VoidCallback fn_new_file
 
VoidCallback fn_new_symlink
 
VoidCallback fn_new_socket
 
VoidCallback fn_new_block_dev
 
VoidCallback fn_new_character_dev
 
VoidCallback fn_new_fifo
 
BoolCallback fn_ignore_file
 
BoolCallback fn_new_dir_prefix
 
VoidCallback fn_new_dir_postfix
 

Private Member Functions

void Init ()
 
void DoRecursion (const std::string &parent_path, const std::string &dir_name) const
 
bool Notify (const BoolCallback callback, const std::string &parent_path, const std::string &entry_name) const
 
void Notify (const VoidCallback callback, const std::string &parent_path, const std::string &entry_name) const
 
std::string GetRelativePath (const std::string &absolute_path) const
 

Private Attributes

T * delegate_
 
std::string relative_to_directory_
 
bool recurse_
 

Detailed Description

template<class T>
class FileSystemTraversal< T >

A simple recursion engine to abstract the recursion of directories. It provides several callback hooks to instrument and control the recursion. Hooks will be called on the provided delegate object of type T.

This file is part of the CernVM File System.

It provides a file system traversal framework to abstract the traversal of directories. Callbacks are called for every directory entry found by the recursion engine. The recursion can be influenced by return values of these callbacks.

Definition at line 37 of file fs_traversal.h.

Member Typedef Documentation

template<class T>
typedef bool(T::* FileSystemTraversal< T >::BoolCallback)(const std::string &relative_path, const std::string &dir_name)

Definition at line 41 of file fs_traversal.h.

template<class T>
typedef void(T::* FileSystemTraversal< T >::VoidCallback)(const std::string &relative_path, const std::string &dir_name)

Definition at line 39 of file fs_traversal.h.

Constructor & Destructor Documentation

template<class T>
FileSystemTraversal< T >::FileSystemTraversal ( T *  delegate,
const std::string &  relative_to_directory,
const bool  recurse 
)
inline

Create a new recursion engine

Parameters
delegateThe object that will receive the callbacks
relative_to_directoryThe DirEntries will be created relative to this directory
recurseShould the traversal engine recurse? (if not, it just traverses the given directory)

Definition at line 87 of file fs_traversal.h.

Here is the call graph for this function:

Member Function Documentation

template<class T>
void FileSystemTraversal< T >::DoRecursion ( const std::string &  parent_path,
const std::string &  dir_name 
) const
inlineprivate

Definition at line 142 of file fs_traversal.h.

Here is the call graph for this function:

template<class T>
std::string FileSystemTraversal< T >::GetRelativePath ( const std::string &  absolute_path) const
inlineprivate

Definition at line 249 of file fs_traversal.h.

template<class T>
void FileSystemTraversal< T >::Init ( )
inlineprivate

Definition at line 139 of file fs_traversal.h.

template<class T>
bool FileSystemTraversal< T >::Notify ( const BoolCallback  callback,
const std::string &  parent_path,
const std::string &  entry_name 
) const
inlineprivate

Definition at line 230 of file fs_traversal.h.

template<class T>
void FileSystemTraversal< T >::Notify ( const VoidCallback  callback,
const std::string &  parent_path,
const std::string &  entry_name 
) const
inlineprivate

Definition at line 239 of file fs_traversal.h.

template<class T>
void FileSystemTraversal< T >::Recurse ( const std::string &  dir_path) const
inline

Start the recursion.

Parameters
dir_pathThe directory to start the recursion at

Definition at line 112 of file fs_traversal.h.

Referenced by swissknife::CommandScrub::Main(), swissknife::CommandGraft::Recurse(), RemoveTree(), publish::SyncUnionAufs::Traverse(), and publish::SyncUnionOverlayfs::Traverse().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

template<class T>
T* FileSystemTraversal< T >::delegate_
private

Definition at line 132 of file fs_traversal.h.

template<class T>
BoolCallback FileSystemTraversal< T >::fn_ignore_file

Optional callback for all files during recursion to decide whether to completely ignore the file. If this callback returns true then the file will not be processed (this is a replacement for the ignored_files set, and it allows to ignore based on names or something else). If the function is not specified, no files will be ignored (except for "." and "..").

Definition at line 62 of file fs_traversal.h.

Referenced by publish::SyncUnionAufs::Traverse(), and publish::SyncUnionOverlayfs::Traverse().

template<class T>
VoidCallback FileSystemTraversal< T >::fn_leave_dir
template<class T>
VoidCallback FileSystemTraversal< T >::fn_new_block_dev
template<class T>
VoidCallback FileSystemTraversal< T >::fn_new_character_dev
template<class T>
VoidCallback FileSystemTraversal< T >::fn_new_dir_postfix

Callback for a found directory after it was already recursed e.g. for deletion of directories: first delete content, then the directory itself

Definition at line 76 of file fs_traversal.h.

template<class T>
BoolCallback FileSystemTraversal< T >::fn_new_dir_prefix

Callback if a directory was found. Depending on the response of the callback, the recursion will continue in the found directory/ If this callback is not specified, it will recurse by default.

Definition at line 69 of file fs_traversal.h.

Referenced by swissknife::CommandGraft::Recurse(), RemoveTree(), publish::SyncUnionAufs::Traverse(), and publish::SyncUnionOverlayfs::Traverse().

template<class T>
VoidCallback FileSystemTraversal< T >::fn_new_fifo
template<class T>
VoidCallback FileSystemTraversal< T >::fn_new_socket
template<class T>
bool FileSystemTraversal< T >::recurse_
private

Definition at line 136 of file fs_traversal.h.

template<class T>
std::string FileSystemTraversal< T >::relative_to_directory_
private

dir_path in callbacks will be relative to this directory

Definition at line 135 of file fs_traversal.h.


The documentation for this class was generated from the following file: