3 * Author : Chris Koeritz
5 * Provides a file transfer utility using the file_transfer_tentacle. *
6 *******************************************************************************
7 * Copyright (c) 2005-$now By Author. This program is free software; you can *
8 * redistribute it and/or modify it under the terms of the GNU General Public *
9 * License as published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) any later version. This is online at: *
11 * http://www.fsf.org/copyleft/gpl.html *
12 * Please send any updates to: fred@gruntose.com
15 #include <application/hoople_main.h>
16 #include <basis/functions.h>
17 #include <loggers/console_logger.h>
18 #include <loggers/critical_events.h>
19 #include <structures/static_memory_gremlin.h>
20 #include <structures/string_array.h>
21 #include <tentacles/file_transfer_tentacle.h>
22 #include <tentacles/recursive_file_copy.h>
24 using namespace application;
25 using namespace basis;
26 using namespace filesystem;
27 using namespace loggers;
28 using namespace octopi;
29 using namespace structures;
30 using namespace textual;
31 using namespace timely;
33 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
35 class synch_files_tentacle : public application_shell
38 synch_files_tentacle() : application_shell() {}
39 DEFINE_CLASS_NAME("test_dirtree_fcopy");
43 int synch_files_tentacle::execute()
47 if (_global_argc < 3) {
49 This program needs two parameters:\n\
50 a directory for the source root and one for the target root.\n\
51 Optionally, a third parameter may specify a starting point within the\n\
53 Further, if fourth or more parameters are found, they are taken to be\n\
54 files to include; only they will be transferred.\n"), ALWAYS_PRINT);
58 astring source_dir = _global_argv[1];
59 astring target_dir = _global_argv[2];
61 astring source_start = "";
62 if (_global_argc >= 4) {
63 source_start = _global_argv[3];
66 string_array includes;
67 if (_global_argc >= 5) {
68 for (int i = 4; i < _global_argc; i++) {
69 includes += _global_argv[i];
73 //hmmm: make comparing the file chunks an option too!
74 outcome returned = recursive_file_copy::copy_hierarchy
75 (file_transfer_tentacle::COMPARE_SIZE_AND_TIME, source_dir,
76 target_dir, includes, source_start);
78 if (returned != common::OKAY) {
79 critical_events::alert_message(astring("copy failure with outcome=")
80 + recursive_file_copy::outcome_name(returned));
85 HOOPLE_MAIN(synch_files_tentacle, )