35 using namespace basis;
45 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s))
51 DEFAULT_SOURCE_DIRECTORY = environment::get(
"FEISTY_MEOW_SCRIPTS");
52 DEFAULT_TARGET_DIRECTORY = environment::get(
"HOME") +
a_sprintf(
"/tftt_junkdir_%d",
randomizer().inclusive(1, 65535));
59 astring DEFAULT_SOURCE_DIRECTORY;
60 astring DEFAULT_TARGET_DIRECTORY;
67 This program needs two parameters:\n\
68 a directory for the source root and one for the target root.\n\
69 Optionally, a third parameter may specify a starting point within the\n\
71 Further, if fourth or more parameters are found, they are taken to be\n\
72 files to include; only they will be transferred.\n");
76 int test_file_transfer_tentacle::execute()
87 if (source_dir.
empty()) {
88 LOG(
astring(
"using default source directory: ") + DEFAULT_SOURCE_DIRECTORY);
89 source_dir = DEFAULT_SOURCE_DIRECTORY;
93 if (target_dir.
empty()) {
94 LOG(
astring(
"using default target directory: ") + DEFAULT_TARGET_DIRECTORY);
95 target_dir = DEFAULT_TARGET_DIRECTORY;
96 bool made_it = directory::make_directory(target_dir);
98 deadly_error(class_name(), func,
astring(
"failed to create target directory for copying: ") + target_dir);
104 if (!source.exists() || !source.is_directory()) {
109 if (!target.exists() || !target.is_directory()) {
126 outcome returned = recursive_file_copy::copy_hierarchy
127 (file_transfer_tentacle::COMPARE_SIZE_AND_TIME, source_dir,
128 target_dir, includes, source_start);
133 if (returned == common::OKAY) {
141 un_int rm_result = launcher.
run(
"rm",
astring(
"-rf ") + target_dir, launch_process::AWAIT_APP_EXIT, kid_id);
142 if (rm_result != 0) {
143 critical_events::alert_message(
astring(class_name()) +
":: failed to remove temporary directory '" + target_dir +
a_sprintf(
"' with OS exit value of %d", rm_result));
145 returned = common::ACCESS_DENIED;
148 if (returned == common::OKAY)
149 critical_events::alert_message(
astring(class_name()) +
":: works for those "
150 "functions tested.");
152 critical_events::alert_message(
astring(class_name()) +
"file_transfer_tentacle:: failed with "
153 "outcome=" + recursive_file_copy::outcome_name(returned));
int print_instructions(bool good, const astring &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.
bool empty() const
empty() reports if the string is empty, that is, of zero length().
Outcomes describe the state of completion for an operation.
Provides operations commonly needed on file names.
Provides the capability to start processes in a variety of ways to run other applications.
static basis::un_int run(const basis::astring &app_name, const basis::astring &command_line, int flag, basis::un_int &child_id)
starts an application using the "app_name" as the executable to run.
An array of strings with some additional helpful methods.
#define deadly_error(c, f, i)
#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.
unsigned int un_int
Abbreviated name for unsigned integers.
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
A dynamic container class that holds any kind of object via pointers.
Useful support functions for unit testing, especially within hoople.