1 #ifndef DIRECTORY_TREE_CLASS
2 #define DIRECTORY_TREE_CLASS
29 class dir_tree_iterator;
33 class fname_tree_creator;
43 bool ignore_files =
false);
59 bool good()
const {
return _scanned_okay; }
180 static bool depth(dir_tree_iterator &scanning,
int &
depth);
187 static bool next(dir_tree_iterator &scanning);
191 static void throw_out(dir_tree_iterator * &to_whack);
202 static filename_tree *goto_current(dir_tree_iterator &scanning);
Provides a dynamically resizable ASCII character string.
A very common template for a dynamic array of bytes.
Outcomes describe the state of completion for an operation.
A base class for objects that can pack into an array of bytes.
An object that traverses directory trees and provides a view of all files.
static bool current(dir_tree_iterator &scanning, filename &dir_name, structures::string_array &to_fill)
retrieves the information for the iterator's current location.
static bool compare_trees(const directory_tree &source, const directory_tree &target, filename_list &differences, file_info::file_similarity how_to_compare)
compares the tree in "source" with the tree in "target".
void text_form(basis::astring &tree_dump, bool show_files=true)
provides a visual representation of the tree in "tree_dump".
filename_tree * seek(const basis::astring &dir_name, bool ignore_initial) const
finds the "dir_name" in our tree.
basis::outcome add_path(const basis::astring &new_item, bool just_size=false)
adds a "new_item" into the tree.
dir_tree_iterator * start_at(filename_tree *start, traversal_types type) const
starts the iterator at a specific "start" node.
static filename_list * access(dir_tree_iterator &scanning)
more dangerous operation that lets the actual list be manipulated.
static bool depth(dir_tree_iterator &scanning, int &depth)
returns the current depth of the iterator.
@ postfix
postfix means that subnodes are traversed first (depth first).
@ prefix
prefix means that subnodes are processed after their parent.
@ infix
infix (for binary trees) goes 1) left, 2) current, 3) right.
basis::outcome remove_path(const basis::astring &zap_item)
removes the "zap_item" from the tree.
virtual bool unpack(basis::byte_array &packed_form)
unpacks the directory_tree from a byte_array.
static void throw_out(dir_tree_iterator *&to_whack)
cleans up an iterator that was previously opened with start().
bool calculate(bool just_size)
visits each file in the directory_tree and calculates its attributes.
virtual int packed_size() const
reports the size after packing up the tree.
DEFINE_CLASS_NAME("directory_tree")
static bool children(dir_tree_iterator &scanning, int &children)
returns the number of children for the current node.
const basis::astring & path() const
returns the root of the directory tree that we manage.
basis::outcome make_directories(const basis::astring new_root)
creates all of the directories in this object, but start at the "new_root".
directory_tree()
constructs an empty tree.
static bool next(dir_tree_iterator &scanning)
goes to the next filename in the "scanning" iterator.
virtual void pack(basis::byte_array &packed_form) const
packs the directory_tree into a byte_array.
dir_tree_iterator * start(traversal_types type) const
starts an iterator on the directory tree.
bool good() const
returns true if the directory existed and we read its contents.
bool reset(const basis::astring &path, const char *pattern="*")
gets rid of any current files and rescans the directory at "path".
static bool jump_to(dir_tree_iterator &scanning, const basis::astring &sub_path)
seeks to a "sub_path" below the iterator's current position.
static bool current_dir(dir_tree_iterator &scanning, filename &dir_name)
sets "dir_name" to the directory name at the "scanning" location.
file_similarity
this enum encapsulates how files may be compared.
Provides operations commonly needed on file names.
this is the tree factory used in the recursive_unpack.
An array of strings with some additional helpful methods.
A platform independent way to obtain the timestamp of a file.