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\
42It expects a directory name to be provided on the command line. If no\n\
43directory is provided, then the current directory is assumed. The sub-\n\
44directories under the chosen directory will be displayed on the console in a\n\
45stylized textual tree. If a second parameter is provided, it is taken as a\n\
46file pattern that causes matching files to be displayed. Without a pattern,\n\
47just 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\
63 if (!depth)
return "";
64 else if (!kids)
return indent +
"|--";
65 else return indent +
"+--";
90 bool show_files =
false;
105 "the directory could not be read");
123 name_to_log = curr.
raw();
128 for (
int i = 0; i <
files.length(); i++) names += files[i] +
" ";
150#ifdef __BUILD_STATIC_APPLICATION__
int print_instructions_and_exit(char *program_name)
The application_shell is a base object for console programs.
virtual int execute()=0
< retrieves the command line from the /proc hierarchy on linux.
application_shell()
constructs an application_shell to serve as the root of the program.
a_sprintf is a specialization of astring that provides printf style support.
Provides a dynamically resizable ASCII character string.
bool t() const
t() is a shortcut for the string being "true", as in non-empty.
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
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.
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 depth(dir_tree_iterator &scanning, int &depth)
returns the current depth of the iterator.
@ prefix
prefix means that subnodes are processed after their parent.
static void throw_out(dir_tree_iterator *&to_whack)
cleans up an iterator that was previously opened with start().
static bool children(dir_tree_iterator &scanning, int &children)
returns the number of children for the current node.
static bool next(dir_tree_iterator &scanning)
goes to the next filename in the "scanning" iterator.
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.
static bool is_eol(char to_check)
returns true if "to_check" is part of an end-of-line sequence.
static void split_lines(const basis::astring &input, basis::astring &output, int min_column=0, int max_column=79)
formats blocks of text for a maximum width.
static basis::astring indentation(int spaces)
Returns a string made of white space that is "spaces" long.
#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.
A dynamic container class that holds any kind of object via pointers.