]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/compute/include/boost/compute/detail/path.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / detail / path.hpp
CommitLineData
7c673cae
FG
1//---------------------------------------------------------------------------//
2// Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
3//
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
7//
8// See http://boostorg.github.com/compute for more information.
9//---------------------------------------------------------------------------//
10
11#ifndef BOOST_COMPUTE_DETAIL_PATH_HPP
12#define BOOST_COMPUTE_DETAIL_PATH_HPP
13
14#include <boost/filesystem/path.hpp>
15#include <boost/filesystem/operations.hpp>
16#include <boost/compute/detail/getenv.hpp>
17
18namespace boost {
19namespace compute {
20namespace detail {
21
22// Path delimiter symbol for the current OS.
23static const std::string& path_delim()
24{
25 static const std::string delim =
26 boost::filesystem::path("/").make_preferred().string();
27 return delim;
28}
29
30// Path to appdata folder.
31inline const std::string& appdata_path()
32{
33 #ifdef WIN32
34 static const std::string appdata = detail::getenv("APPDATA")
35 + path_delim() + "boost_compute";
36 #else
37 static const std::string appdata = detail::getenv("HOME")
38 + path_delim() + ".boost_compute";
39 #endif
40 return appdata;
41}
42
43// Path to cached binaries.
44inline std::string program_binary_path(const std::string &hash, bool create = false)
45{
46 std::string dir = detail::appdata_path() + path_delim()
47 + hash.substr(0, 2) + path_delim()
48 + hash.substr(2);
49
50 if(create && !boost::filesystem::exists(dir)){
51 boost::filesystem::create_directories(dir);
52 }
53
54 return dir + path_delim();
55}
56
57// Path to parameter caches.
58inline std::string parameter_cache_path(bool create = false)
59{
60 const static std::string dir = appdata_path() + path_delim() + "tune";
61
62 if(create && !boost::filesystem::exists(dir)){
63 boost::filesystem::create_directories(dir);
64 }
65
66 return dir + path_delim();
67}
68
69} // end detail namespace
70} // end compute namespace
71} // end boost namespace
72
73#endif // BOOST_COMPUTE_DETAIL_PATH_HPP