Ignition Common

API Reference

4.4.0
SystemPaths.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
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 #ifndef IGNITION_COMMON_SYSTEMPATHS_HH_
18 #define IGNITION_COMMON_SYSTEMPATHS_HH_
19 
20 #include <stdio.h>
21 
22 #ifdef _WIN32
23  #include <direct.h>
24  #define GetCurrentDir _getcwd
25 #else
26  #include <unistd.h>
27  #define GetCurrentDir getcwd
28 #endif
29 
30 #include <functional>
31 #include <list>
32 #include <memory>
33 #include <string>
34 #include <vector>
35 
36 #include <ignition/common/Export.hh>
38 #include <ignition/common/URI.hh>
39 
40 namespace ignition
41 {
42  namespace common
43  {
44  // Forward declare private data class
45  class SystemPathsPrivate;
46 
51  class IGNITION_COMMON_VISIBLE SystemPaths
52  {
54  public: SystemPaths();
55 
57  public: virtual ~SystemPaths();
58 
64  public: std::string LogPath() const;
65 
68  public: const std::list<std::string> &PluginPaths();
69 
75  public: std::string FindFileURI(const std::string &_uri) const;
76 
84  public: std::string FindFileURI(const ignition::common::URI &_uri) const;
85 
88  public: void SetPluginPathEnv(const std::string &_env);
89 
97  public: std::string FindFile(const std::string &_filename,
98  const bool _searchLocalPath = true,
99  const bool _verbose = true) const;
100 
109  public: std::string FindSharedLibrary(const std::string &_libName);
110 
113  public: void AddPluginPaths(const std::string &_path);
114 
116  public: void ClearPluginPaths();
117 
125  public: void SetFilePathEnv(const std::string &_env);
126 
133  public: std::string FilePathEnv() const;
134 
137  public: const std::list<std::string> &FilePaths();
138 
144  public: void AddFilePaths(const std::string &_path);
145 
147  public: void ClearFilePaths();
148 
151  public: void AddSearchPathSuffix(const std::string &_suffix);
152 
159  public: void IGN_DEPRECATED(3) SetFindFileCallback(
160  std::function<std::string(const std::string &)> _cb);
161 
171  public: void AddFindFileCallback(
172  std::function<std::string(const std::string &)> _cb);
173 
183  public: void AddFindFileURICallback(
185 
192  public: void IGN_DEPRECATED(3) SetFindFileURICallback(
193  std::function<std::string(const std::string &)> _cb);
194 
206  public: static std::string LocateLocalFile(const std::string &_filename,
207  const std::vector<std::string> &_paths);
208 
213  public: static std::string NormalizeDirectoryPath(
214  const std::string &_path);
215 
219  public: static std::list<std::string> PathsFromEnv(
220  const std::string &_env);
221 
224  public: static char Delimiter();
225 
228  private: std::unique_ptr<SystemPathsPrivate> dataPtr;
230  };
231  }
232 }
233 #endif
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: SuppressWarning.hh:67
STL class.
A complete URI which has the following components:
Definition: URI.hh:406
Functions to handle getting system paths, keeps track of:
Definition: SystemPaths.hh:51
STL class.
STL class.
Forward declarations for the common classes.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: SuppressWarning.hh:64