irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

irods_get_full_path_for_config_file.cpp
Go to the documentation of this file.
1 // =-=-=-=-=-=-=-
2 // boost includes
3 #include <boost/filesystem.hpp>
4 #include <boost/filesystem/operations.hpp>
5 #include <boost/filesystem/path.hpp>
6 
7 // =-=-=-=-=-=-=-
8 // stl includes
9 #include <vector>
10 
11 // =-=-=-=-=-=-=-
12 // irods includes
13 #include "rodsErrorTable.h"
14 #include "irods_log.hpp"
16 #include "irods_default_paths.hpp"
17 #include "irods_exception.hpp"
18 
19 namespace irods {
21  const std::string& _cfg_file,
22  std::string& _full_path ) {
23  namespace fs = boost::filesystem;
24 
25  try {
26  fs::path path = get_irods_config_directory();
27  path.append(_cfg_file);
28  if ( fs::exists(path) ) {
29  _full_path = path.string();
30  rodsLog( LOG_DEBUG, "config file found [%s]", _full_path.c_str() );
31  return SUCCESS();
32  }
33  } catch (const irods::exception& e) {
34  irods::log(e);
35  return ERROR(-1, "failed to get irods home directory");
36  }
37 
38  std::string msg( "config file not found [" );
39  msg += _cfg_file + "]";
40  return ERROR(SYS_INVALID_INPUT_PARAM, msg);
41  }
42 
44  const std::string& _cfg_file,
45  std::string& _full_path ) {
46  namespace fs = boost::filesystem;
47 
48  try {
49  fs::path path = get_irods_home_directory();
50  path.append("config").append(_cfg_file);
51  if ( fs::exists(path) ) {
52  _full_path = path.string();
53  rodsLog( LOG_DEBUG, "config file found [%s]", _full_path.c_str() );
54  return SUCCESS();
55  }
56  } catch (const irods::exception& e) {
57  irods::log(e);
58  return ERROR(-1, "failed to get irods home directory");
59  }
60 
61  std::string msg( "config file not found [" );
62  msg += _cfg_file + "]";
63  return ERROR(SYS_INVALID_INPUT_PARAM, msg);
64  }
65 }
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
irods::get_full_path_for_config_file
error get_full_path_for_config_file(const std::string &, std::string &)
Definition: irods_get_full_path_for_config_file.cpp:20
irods::get_irods_home_directory
boost::filesystem::path get_irods_home_directory()
Definition: irods_default_paths.cpp:36
irods_get_full_path_for_config_file.hpp
irods::get_irods_config_directory
boost::filesystem::path get_irods_config_directory()
Definition: irods_default_paths.cpp:29
irods_exception.hpp
irods::experimental::administration::client::v1::exists
auto exists(rcComm_t &conn, const user &user) -> bool
Definition: user_administration.cpp:359
irods_default_paths.hpp
irods::get_full_path_for_unmoved_configs
error get_full_path_for_unmoved_configs(const std::string &, std::string &)
Definition: irods_get_full_path_for_config_file.cpp:43
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
LOG_DEBUG
#define LOG_DEBUG
Definition: rodsLog.h:23
irods
Definition: apiHandler.hpp:35
terminate_irods_processes.e
e
Definition: terminate_irods_processes.py:19
irods::log
void log(const error &)
Definition: irods_log.cpp:13
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::error
Definition: irods_error.hpp:23
irods::exception
Definition: irods_exception.hpp:15
rodsErrorTable.h
irods_log.hpp