Chris@16
|
1 /*
|
Chris@16
|
2 * Distributed under the Boost Software License, Version 1.0.(See accompanying
|
Chris@16
|
3 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
|
Chris@16
|
4 *
|
Chris@16
|
5 * See http://www.boost.org/libs/iostreams for documentation.
|
Chris@16
|
6
|
Chris@16
|
7 * File: boost/iostreams/detail/execute.hpp
|
Chris@16
|
8 * Date: Thu Dec 06 13:21:54 MST 2007
|
Chris@16
|
9 * Copyright: 2007-2008 CodeRage, LLC
|
Chris@16
|
10 * Author: Jonathan Turkanis
|
Chris@16
|
11 * Contact: turkanis at coderage dot com
|
Chris@16
|
12 *
|
Chris@16
|
13 * Defines the function boost::iostreams::detail::absolute_path, used for
|
Chris@16
|
14 * debug output for mapped files.
|
Chris@16
|
15 */
|
Chris@16
|
16
|
Chris@16
|
17 #ifndef BOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED
|
Chris@16
|
18 #define BOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED
|
Chris@16
|
19
|
Chris@16
|
20 #include <string>
|
Chris@16
|
21 #include <boost/iostreams/detail/config/windows_posix.hpp>
|
Chris@16
|
22 #ifdef BOOST_IOSTREAMS_WINDOWS
|
Chris@16
|
23 # include <cctype>
|
Chris@16
|
24 #endif
|
Chris@16
|
25 #include <boost/iostreams/detail/current_directory.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 namespace boost { namespace iostreams { namespace detail {
|
Chris@16
|
28
|
Chris@16
|
29 // Resolves the given path relative to the current working directory
|
Chris@16
|
30 inline std::string absolute_path(const std::string& path)
|
Chris@16
|
31 {
|
Chris@16
|
32 #ifdef BOOST_IOSTREAMS_WINDOWS
|
Chris@16
|
33 return path.size() && (path[0] == '/' || path[0] == '\\') ||
|
Chris@16
|
34 path.size() > 1 && std::isalpha(path[0]) && path[1] == ':' ?
|
Chris@16
|
35 path :
|
Chris@16
|
36 current_directory() + '\\' + path;
|
Chris@16
|
37 #else // #ifdef BOOST_IOSTREAMS_WINDOWS
|
Chris@16
|
38 return path.size() && (path[0] == '/') ?
|
Chris@16
|
39 path :
|
Chris@16
|
40 current_directory() + '/' + path;
|
Chris@16
|
41 #endif // #ifdef BOOST_IOSTREAMS_WINDOWS
|
Chris@16
|
42 }
|
Chris@16
|
43
|
Chris@16
|
44 } } } // End namespaces detail, iostreams, boost.
|
Chris@16
|
45
|
Chris@16
|
46 #endif // #ifndef BOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED
|