File indexing completed on 2024-11-15 09:04:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_COMPUTE_DETAIL_PATH_HPP
0012 #define BOOST_COMPUTE_DETAIL_PATH_HPP
0013
0014 #include <boost/filesystem/path.hpp>
0015 #include <boost/filesystem/operations.hpp>
0016 #include <boost/compute/detail/getenv.hpp>
0017
0018 namespace boost {
0019 namespace compute {
0020 namespace detail {
0021
0022
0023 static const std::string& path_delim()
0024 {
0025 static const std::string delim =
0026 boost::filesystem::path("/").make_preferred().string();
0027 return delim;
0028 }
0029
0030
0031 inline const std::string& appdata_path()
0032 {
0033 #ifdef _WIN32
0034 static const std::string appdata = detail::getenv("APPDATA")
0035 + path_delim() + "boost_compute";
0036 #else
0037 static const std::string appdata = detail::getenv("HOME")
0038 + path_delim() + ".boost_compute";
0039 #endif
0040 return appdata;
0041 }
0042
0043
0044 inline std::string program_binary_path(const std::string &hash, bool create = false)
0045 {
0046 std::string dir = detail::appdata_path() + path_delim()
0047 + hash.substr(0, 2) + path_delim()
0048 + hash.substr(2);
0049
0050 if(create && !boost::filesystem::exists(dir)){
0051 boost::filesystem::create_directories(dir);
0052 }
0053
0054 return dir + path_delim();
0055 }
0056
0057
0058 inline std::string parameter_cache_path(bool create = false)
0059 {
0060 const static std::string dir = appdata_path() + path_delim() + "tune";
0061
0062 if(create && !boost::filesystem::exists(dir)){
0063 boost::filesystem::create_directories(dir);
0064 }
0065
0066 return dir + path_delim();
0067 }
0068
0069 }
0070 }
0071 }
0072
0073 #endif