libqi-api  2.1.4.13
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
path.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3  * Copyright (c) 2012 Aldebaran Robotics. All rights reserved.
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the COPYING file.
6  */
7 
12 #ifndef _QI_PATH_HPP_
13 #define _QI_PATH_HPP_
14 
15 # include <string>
16 # include <vector>
17 # include <boost/shared_ptr.hpp>
18 # include <qi/api.hpp>
19 
20 namespace qi
21 {
22 
23  class PrivatePath;
24  class Path;
25  typedef std::vector<Path> PathVector;
26  class QI_API Path {
27  public:
28  Path(const std::string& unicodePath = std::string());
29 
30  bool isEmpty() const;
31  bool isDir() const;
32  bool isRegularFile() const;
33 
34  std::string filename() const;
35  std::string extension() const;
36 
37  Path parent();
38  Path absolute();
39 
40  PathVector files();
41  PathVector dirs();
42 
43  operator std::string() const;
44 
45  Path operator/(const qi::Path& rhs) const;
46  const Path& operator/=(const qi::Path& rhs) const;
47 
48  private:
49  Path(const boost::shared_ptr<PrivatePath> &p);;
50  boost::shared_ptr<PrivatePath> _p;
51  };
52 
54  namespace path
55  {
56 
58  QI_API std::string sdkPrefix();
59 
60  // not thread-safe, must be kept internal
61  namespace detail {
62 
67  QI_API std::vector<std::string> getSdkPrefixes();
68 
78  QI_API void addOptionalSdkPrefix(const char* prefix);
79 
87 
88  }
89 
91  QI_API std::string findBin(const std::string& name);
92 
94  QI_API std::string findLib(const std::string& name);
95 
97  QI_API std::string findConf(const std::string& applicationName,
98  const std::string& filename);
99 
102  QI_API std::string findData(const std::string& applicationName,
103  const std::string& filename);
104 
109  QI_API std::vector<std::string> listData(const std::string& applicationName,
110  const std::string& pattern="*");
111 
113  QI_API std::vector<std::string> confPaths(const std::string& applicationName="");
114 
116  QI_API std::vector<std::string> dataPaths(const std::string& applicationName="");
117 
119  QI_API std::vector<std::string> binPaths();
120 
122  QI_API std::vector<std::string> libPaths();
123 
124 
126  QI_API void setWritablePath(const std::string &path);
127 
129  QI_API std::string userWritableDataPath(const std::string& applicationName,
130  const std::string& filename);
131 
133  QI_API std::string userWritableConfPath(const std::string& applicationName,
134  const std::string& filename="");
135 
144  QI_API std::string convertToDosPath(const std::string &pathString);
145  }
146 }
147 
148 #endif // _QI_PATH_HPP_
std::string findLib(const std::string &name)
Look for a library.
std::string sdkPrefix()
Return the default SDK prefix path.
std::vector< std::string > getSdkPrefixes()
Return the SDK prefixes list. It's always complete, native paths.
void clearOptionalSdkPrefix()
Reset the list of additional SDK prefixes.
std::string convertToDosPath(const std::string &pathString)
void setWritablePath(const std::string &path)
Set the writable files path for users.
std::vector< std::string > confPaths(const std::string &applicationName="")
Get the list of directories used when searching for configuration files for the given application nam...
std::vector< Path > PathVector
Definition: path.hpp:24
std::vector< std::string > dataPaths(const std::string &applicationName="")
Get the list of directories used when searching for data files for the given application name...
std::vector< std::string > listData(const std::string &applicationName, const std::string &pattern="*")
std::string findBin(const std::string &name)
Look for a binary.
void addOptionalSdkPrefix(const char *prefix)
Add a new SDK prefix to the list of searchable prefixes.
std::string findConf(const std::string &applicationName, const std::string &filename)
Look for a configuration file.
std::string userWritableDataPath(const std::string &applicationName, const std::string &filename)
Get the writable data files path for users.
dll import/export and compiler message
std::vector< std::string > binPaths()
Get the list of directories used when searching for binaries.
std::vector< std::string > libPaths()
Get the list of directories used when searching for libraries.
std::string userWritableConfPath(const std::string &applicationName, const std::string &filename="")
Get the writable configuration files path for users.
#define QI_API
Definition: api.hpp:24
std::string findData(const std::string &applicationName, const std::string &filename)