libqi-api
2.1.0.18
|
00001 #pragma once 00002 /* 00003 * Copyright (c) 2012 Aldebaran Robotics. All rights reserved. 00004 * Use of this source code is governed by a BSD-style license that can be 00005 * found in the COPYING file. 00006 */ 00007 00012 #ifndef _QI_PATH_HPP_ 00013 #define _QI_PATH_HPP_ 00014 00015 # include <string> 00016 # include <vector> 00017 # include <boost/shared_ptr.hpp> 00018 # include <qi/api.hpp> 00019 00020 namespace qi 00021 { 00022 00023 class PrivatePath; 00024 class Path; 00025 typedef std::vector<Path> PathVector; 00026 class QI_API Path { 00027 public: 00028 Path(const std::string& unicodePath = std::string()); 00029 00030 bool isEmpty() const; 00031 bool isDir() const; 00032 bool isRegularFile() const; 00033 00034 std::string filename() const; 00035 std::string extension() const; 00036 00037 Path parent(); 00038 Path absolute(); 00039 00040 PathVector files(); 00041 PathVector dirs(); 00042 00043 operator std::string() const; 00044 00045 Path operator/(const qi::Path& rhs) const; 00046 const Path& operator/=(const qi::Path& rhs) const; 00047 00048 private: 00049 Path(const boost::shared_ptr<PrivatePath> &p);; 00050 boost::shared_ptr<PrivatePath> _p; 00051 }; 00052 00054 namespace path 00055 { 00056 00058 QI_API std::string sdkPrefix(); 00059 00060 // not thread-safe, must be kept internal 00061 namespace detail { 00062 00067 QI_API std::vector<std::string> getSdkPrefixes(); 00068 00078 QI_API void addOptionalSdkPrefix(const char* prefix); 00079 00086 QI_API void clearOptionalSdkPrefix(); 00087 00088 } 00089 00091 QI_API std::string findBin(const std::string& name); 00092 00094 QI_API std::string findLib(const std::string& name); 00095 00097 QI_API std::string findConf(const std::string& applicationName, 00098 const std::string& filename); 00099 00102 QI_API std::string findData(const std::string& applicationName, 00103 const std::string& filename); 00104 00109 QI_API std::vector<std::string> listData(const std::string& applicationName, 00110 const std::string& pattern="*"); 00111 00113 QI_API std::vector<std::string> confPaths(const std::string& applicationName=""); 00114 00116 QI_API std::vector<std::string> dataPaths(const std::string& applicationName=""); 00117 00119 QI_API std::vector<std::string> binPaths(); 00120 00122 QI_API std::vector<std::string> libPaths(); 00123 00124 00126 QI_API void setWritablePath(const std::string &path); 00127 00129 QI_API std::string userWritableDataPath(const std::string& applicationName, 00130 const std::string& filename); 00131 00133 QI_API std::string userWritableConfPath(const std::string& applicationName, 00134 const std::string& filename=""); 00135 00144 QI_API std::string convertToDosPath(const std::string &pathString); 00145 } 00146 } 00147 00148 #endif // _QI_PATH_HPP_