CARMA C++
RuntimeDirs.h
1 #ifndef CARMA_UTIL_RUNTIMEDIRS_H
2 #define CARMA_UTIL_RUNTIMEDIRS_H
3 
4 
5 /*
6  * @file
7  *
8  * Class to get all of the runtime directories for a carma Program.
9  * Contains only static methods.
10  *
11  * @author Original:Steve Scott
12  * $id: $
13  *
14  * $CarmaCopyright$
15  *
16  */
17 
18 
19 
20 
21 namespace carma {
22  namespace util {
23 
24 
59 class RuntimeDirs {
60 public:
61 
77  static std::string getConfFile(const std::string& programName,
78  const std::string& confFilename);
79 
89  static std::string getConfDir(const std::string& programName);
90 
101  static std::string getRootDir(const std::string& programName);
102 
109  static std::string getExecutableDir(const std::string& programName);
110 
118  static std::string getExecutable(const std::string& programName);
119 
120 private:
121  // Disable construction.
122  RuntimeDirs();
123  /*
124  * Get the full path to the executable, using bash "which" command
125  * @param programName as invoked (e.g. arg0)
126  * @return canonicalized full path binary filename
127  */
128  static std::string findExecutable(const std::string& programName);
129  /*
130  * @throws ErrorException if realpath() fails
131  */
132  static std::string canonicalize(const std::string& filename);
133  // Like basename() and dirname() except for strings rather than char*'s
134  static std::string basenameString(const std::string& filename);
135  static std::string dirnameString(const std::string& filename);
136  // Lop off any trailing slashes
137  static std::string trim(const std::string& filename);
138 
139 };
140 
141 }} // End namespace carma::util
142 
143 #endif // CARMA_UTIL_RUNTIMEDIRS_H
static std::string getConfDir(const std::string &programName)
Get the configuration directory - assumes standard carma tree.
This class is a collection of static methods to return specific directories for a standard carma tree...
Definition: RuntimeDirs.h:59
static std::string getExecutableDir(const std::string &programName)
Get the directory where this program executable lives.
static std::string getConfFile(const std::string &programName, const std::string &confFilename)
Get the absolute path of a configuration file.
static std::string getExecutable(const std::string &programName)
Get absolute full path of executable, including program executable.
static std::string getRootDir(const std::string &programName)
Get the root build or install directory - assumes standard carma tree.