1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_DETAIL_PATH_HPP
12 #define BOOST_COMPUTE_DETAIL_PATH_HPP
14 #include <boost/filesystem/path.hpp>
15 #include <boost/filesystem/operations.hpp>
16 #include <boost/compute/detail/getenv.hpp>
22 // Path delimiter symbol for the current OS.
23 static const std::string& path_delim()
25 static const std::string delim =
26 boost::filesystem::path("/").make_preferred().string();
30 // Path to appdata folder.
31 inline const std::string& appdata_path()
34 static const std::string appdata = detail::getenv("APPDATA")
35 + path_delim() + "boost_compute";
37 static const std::string appdata = detail::getenv("HOME")
38 + path_delim() + ".boost_compute";
43 // Path to cached binaries.
44 inline std::string program_binary_path(const std::string &hash, bool create = false)
46 std::string dir = detail::appdata_path() + path_delim()
47 + hash.substr(0, 2) + path_delim()
50 if(create && !boost::filesystem::exists(dir)){
51 boost::filesystem::create_directories(dir);
54 return dir + path_delim();
57 // Path to parameter caches.
58 inline std::string parameter_cache_path(bool create = false)
60 const static std::string dir = appdata_path() + path_delim() + "tune";
62 if(create && !boost::filesystem::exists(dir)){
63 boost::filesystem::create_directories(dir);
66 return dir + path_delim();
69 } // end detail namespace
70 } // end compute namespace
71 } // end boost namespace
73 #endif // BOOST_COMPUTE_DETAIL_PATH_HPP