Debian Codegraph @

src/tools/davix_tool_mv_main.cpp

raw
1 /*
2 * This File is part of Davix, The IO library for HTTP based protocols
3 * Copyright (C) CERN 2013
4 * Author: Kwong Tat Cheung <[email protected]>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22 #include <davix_internal.hpp>
23 #include <davix.hpp>
24 #include <tools/davix_tool_params.hpp>
25 #include <tools/davix_tool_util.hpp>
26 #include <cstdio>
27
28 using namespace Davix;
29 using namespace std;
30
31 #define READ_BLOCK_SIZE 4096
32
33
34 const std::string scope_main = "Davix::Tools::davix-mv";
35
36
37
38 static std::string help_msg(const std::string & cmd_path){
39 std::string help_msg = fmt::format("Usage : {} ", cmd_path);
40 help_msg += Tool::get_base_description_options();
41 help_msg += Tool::get_common_options();
42
43 return help_msg;
44 }
45
46
47
48 int main(int argc, char** argv){
49 int retcode=-1;
50 Tool::OptParams opts;
51 DavixError* tmp_err=NULL;
52 opts.help_msg = help_msg(argv[0]);
53
54 TRY_DAVIX{
55 if( (retcode= Tool::parse_davix_options(argc, argv, opts, &tmp_err)) ==0){
56 Context c;
57
58 if( (retcode = Tool::configureAuth(opts)) == 0){
59 configureContext(c, opts);
60 File source(c, opts.vec_arg[0]), dest(c, opts.vec_arg[1]);
61
62
63 source.move(&opts.params, dest);
64 retcode =0;
65 }
66 }
67 }CATCH_DAVIX(&tmp_err){
68 retcode = -1;
69 }
70
71 Tool::errorPrint(&tmp_err);
72 return retcode;
73 }
74