upload tizen1.0 source
[framework/web/wrt-plugins-common.git] / src / modules / tizen / Filesystem / Command.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  * @author          Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
18  */
19
20 #include "Command.h"
21 #include <cstdlib>
22 #include <Commons/Exception.h>
23
24 namespace WrtDeviceApis {
25 namespace Filesystem {
26
27 void Command::execute()
28 {
29     int result = system(prepare().c_str());
30     if (-1 != result) {
31         if (0 != WIFEXITED(result)) {
32             if (0 != WEXITSTATUS(result)) {
33                 ThrowMsg(Commons::PlatformException, "Command failed.");
34             }
35         } else {
36             ThrowMsg(Commons::PlatformException,
37                      "Command terminated abnormally.");
38         }
39     } else {
40         ThrowMsg(Commons::PlatformException, "Couldn't launch command.");
41     }
42 }
43
44 }
45 }