Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:04:26

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
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 // Path delimiter symbol for the current OS.
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 // Path to appdata folder.
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 // Path to cached binaries.
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 // Path to parameter caches.
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 } // end detail namespace
0070 } // end compute namespace
0071 } // end boost namespace
0072 
0073 #endif // BOOST_COMPUTE_DETAIL_PATH_HPP