update for beta universally
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Filesystem / CopyCommand.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License. 
15  */
16
17
18 #include "CopyCommand.h"
19 #include <sstream>
20
21 namespace {
22 const char* COMMAND_NAME = "/bin/cp";
23 const char* COMMAND_SWITCH_RECURSIVE = "-r";
24 const char* COMMAND_SWITCH_FORCE = "-f";
25 }
26
27 namespace TizenApis {
28 namespace Platform {
29 namespace Filesystem {
30 CopyCommand::CopyCommand(const Api::Filesystem::IPathPtr& src,
31         const Api::Filesystem::IPathPtr& dest) :
32     m_src(src),
33     m_dest(dest),
34     m_recursive(false),
35     m_force(false)
36 {
37 }
38
39 void CopyCommand::setRecursive(bool recursive)
40 {
41     m_recursive = recursive;
42 }
43
44 void CopyCommand::setForce(bool force)
45 {
46     m_force = force;
47 }
48
49 std::string CopyCommand::prepare()
50 {
51     std::ostringstream oss;
52     oss << COMMAND_NAME;
53
54     if (m_recursive) {
55         oss << " " << COMMAND_SWITCH_RECURSIVE;
56     }
57
58     if (m_force) {
59         oss << " " << COMMAND_SWITCH_FORCE;
60     }
61
62     oss << " \"" << m_src->getFullPath().c_str() << "\"";
63     oss << " \"" << m_dest->getFullPath().c_str() << "\"";
64
65     return oss.str();
66 }
67 }
68 }
69 }