25 using namespace basis;
31 #define LOG(to_print) EMERGENCY_LOG(program_wide_logger::get(), to_print)
41 %s: This utility shows the sub-directory structure for a chosen directory.\n\
42 It expects a directory name to be provided on the command line. If no\n\
43 directory is provided, then the current directory is assumed. The sub-\n\
44 directories under the chosen directory will be displayed on the console in a\n\
45 stylized textual tree. If a second parameter is provided, it is taken as a\n\
46 file pattern that causes matching files to be displayed. Without a pattern,\n\
47 just the directory tree is shown.\n\
50 => shows the directory structure of the current directory.\n\
52 => shows the structure of directory 'udon'\n\
53 dirtree soba \"*.txt\"\n\
54 => displays all text files and sub-directories of 'soba'\n\
62 astring indent = string_manipulation::indentation( (depth - 1) * 2);
63 if (!depth)
return "";
64 else if (!kids)
return indent +
"|--";
65 else return indent +
"+--";
68 int dirtree::execute()
90 bool show_files =
false;
105 "the directory could not be read");
109 dir_tree_iterator *ted = dir.start(directory_tree::prefix);
117 while (directory_tree::current(*ted, curr,
files)) {
119 directory_tree::depth(*ted, depth);
120 directory_tree::children(*ted, kids);
123 name_to_log = curr.
raw();
128 for (
int i = 0; i <
files.length(); i++) names +=
files[i] +
" ";
141 directory_tree::next(*ted);
144 directory_tree::throw_out(ted);
150 #ifdef __BUILD_STATIC_APPLICATION__
int print_instructions_and_exit(char *program_name)
The application_shell is a base object for console programs.
a_sprintf is a specialization of astring that provides printf style support.
Provides a dynamically resizable ASCII character string.
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
bool t() const
t() is a shortcut for the string being "true", as in non-empty.
virtual void zap(int start, int end)
Deletes the characters between "start" and "end" inclusively.
int end() const
returns the index of the last (non-null) character in the string.
int length() const
Returns the current length of the string.
An object that traverses directory trees and provides a view of all files.
Provides operations commonly needed on file names.
const basis::astring & raw() const
returns the astring that we're holding onto for the path.
filename basename() const
returns the base of the filename; no directory.
An array of strings with some additional helpful methods.
#define continuable_error(c, f, i)
astring hier_prefix(int depth, int kids)
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
Provides macros that implement the 'main' program of an application.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
None split_lines(str unsplit_line)
A dynamic container class that holds any kind of object via pointers.
bool is_eol(char to_check)