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 #define DEBUG_SYNCH_FILES
36 //hmmm: not used yet, but should be.
38 class synch_files_tentacle : public application_shell
41 synch_files_tentacle() : application_shell() {}
42 DEFINE_CLASS_NAME("test_dirtree_fcopy");
46 int synch_files_tentacle::execute()
50 if (_global_argc < 3) {
52 This program needs two parameters:\n\
53 a directory for the source root and one for the target root.\n\
54 Optionally, a third parameter may specify a starting point within the\n\
56 Further, if fourth or more parameters are found, they are taken to be\n\
57 files to include; only they will be transferred.\n"), ALWAYS_PRINT);
61 astring source_dir = _global_argv[1];
62 astring target_dir = _global_argv[2];
64 astring source_start = "";
65 if (_global_argc >= 4) {
66 source_start = _global_argv[3];
69 string_array includes;
70 if (_global_argc >= 5) {
71 for (int i = 4; i < _global_argc; i++) {
72 includes += _global_argv[i];
76 //hmmm: make comparing the file chunks an option too!
77 outcome returned = recursive_file_copy::copy_hierarchy
78 (file_transfer_tentacle::COMPARE_SIZE_AND_TIME, source_dir,
79 target_dir, includes, source_start);
81 if (returned != common::OKAY) {
82 critical_events::alert_message(astring("copy failure with outcome=")
83 + recursive_file_copy::outcome_name(returned));
88 HOOPLE_MAIN(synch_files_tentacle, )