34 using namespace basis;
39 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
49 int test_fcopy::execute()
60 source_dir = environment::get(
"FEISTY_MEOW_SCRIPTS");
61 target_dir = environment::get(
"FEISTY_MEOW_SCRIPTS");
68 log(
astring(
"Scanning source tree at \"") + source_dir +
"\"");
72 "the source directory could not be read");
75 log(
astring(
"Scanning target tree at \"") + target_dir +
"\"");
79 "the target directory could not be read");
81 LOG(
"calculating checksums for source.");
82 if (!source.calculate(
true))
84 "the source tree could not be calculated");
86 LOG(
"calculating checksums for target.");
87 if (!target.calculate(
true))
89 "the target tree could not be calculated");
98 LOG(
"comparing the two trees.");
100 directory_tree::compare_trees(source, source_start, target, target_start,
101 diffs, file_info::EQUAL_CHECKSUM_TIMESTAMP_FILESIZE);
106 diffs.
pack(packed_form);
108 if (!regen.
unpack(packed_form))
110 "could not unpack the list of differences");
117 "there were a different number of elements in unpacked form");
118 for (
int i = 0; i < diffs.
elements(); i++) {
119 if (!regen.
member(*diffs[i])) {
122 astring(
"name from original set was missing in regenerated: ")
127 for (
int i = 0; i < diffs.
elements(); i++) {
129 filename source_file = source.path() + filename::default_separator()
131 filename target_file = target.path() + filename::default_separator()
137 bool worked = directory::recursive_create(targ_dir);
140 astring(
"failed to create the target directory ") + targ_dir);
143 outcome ret = heavy_file_operations::copy_file(source_file, target_file);
144 if (ret != heavy_file_operations::OKAY)
146 + heavy_file_operations::outcome_name(ret)
147 +
" when copying the file.");
157 critical_events::alert_message(
"directory_tree file transfer:: works for those functions tested.");
The application_shell is a base object for console programs.
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.
An object that traverses directory trees and provides a view of all files.
Encapsulates some measures and calculations based on a file's contents.
const basis::astring & secondary() const
observes the alternate form of the name.
bool member(const filename &to_check) const
finds the index for "to_find" or returns a negative number.
virtual void pack(basis::byte_array &packed_form) const
Creates a packed form of the packable object in "packed_form".
virtual bool unpack(basis::byte_array &packed_form)
Restores the packable from the "packed_form".
Provides operations commonly needed on file names.
bool is_directory() const
const basis::astring & raw() const
returns the astring that we're holding onto for the path.
filename dirname() const
returns the directory for the filename.
int elements() const
the maximum number of elements currently allowed in this amorph.
#define non_continuable_error(c, f, i)
an extra piece of information used, if available, in bounds_halt below.
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
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.
Useful support functions for unit testing, especially within hoople.