1 /*
2 ** Copyright 2012-2013 Centreon
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 ** For more information : contact@centreon.com
17 */
18 
19 #include <cstdlib>
20 #include <iostream>
21 #include "com/centreon/exceptions/basic.hh"
22 #include "com/centreon/io/file_entry.hh"
23 
24 using namespace com::centreon;
25 
26 /**
27  *  Check permission is valid.
28  *
29  *  @return EXIT_SUCCESS on success.
30  */
main(int argc,char * argv[])31 int main(int argc, char* argv[]) {
32   (void)argc;
33 
34   int ret(EXIT_FAILURE);
35   try {
36     io::file_entry entry(argv[0]);
37     if (entry.is_directory())
38       throw(basic_error() << "permission failed: is not a directory");
39     if (entry.is_link())
40       throw(basic_error() << "permission failed: is not a link");
41     if (!entry.is_regular())
42       throw(basic_error() << "permission failed: is a regular file");
43 
44     ret = EXIT_SUCCESS;
45   } catch (std::exception const& e) {
46     std::cerr << e.what() << std::endl;
47   }
48   return (ret);
49 }
50