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