/Src/Dependencies/Boost/boost/iostreams/detail/absolute_path.hpp

http://hadesmem.googlecode.com/ · C++ Header · 46 lines · 24 code · 6 blank · 16 comment · 9 complexity · 6e30b4bc1a57b45f0d458f53f4f1b54e MD5 · raw file

  1. /*
  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. * File: boost/iostreams/detail/execute.hpp
  7. * Date: Thu Dec 06 13:21:54 MST 2007
  8. * Copyright: 2007-2008 CodeRage, LLC
  9. * Author: Jonathan Turkanis
  10. * Contact: turkanis at coderage dot com
  11. *
  12. * Defines the function boost::iostreams::detail::absolute_path, used for
  13. * debug output for mapped files.
  14. */
  15. #ifndef BOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED
  16. #define BOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED
  17. #include <string>
  18. #include <boost/iostreams/detail/config/windows_posix.hpp>
  19. #ifdef BOOST_IOSTREAMS_WINDOWS
  20. # include <cctype>
  21. #endif
  22. #include <boost/iostreams/detail/current_directory.hpp>
  23. namespace boost { namespace iostreams { namespace detail {
  24. // Resolves the given path relative to the current working directory
  25. inline std::string absolute_path(const std::string& path)
  26. {
  27. #ifdef BOOST_IOSTREAMS_WINDOWS
  28. return path.size() && (path[0] == '/' || path[0] == '\\') ||
  29. path.size() > 1 && std::isalpha(path[0]) && path[1] == ':' ?
  30. path :
  31. current_directory() + '\\' + path;
  32. #else // #ifdef BOOST_IOSTREAMS_WINDOWS
  33. return path.size() && (path[0] == '/') ?
  34. path :
  35. current_directory() + '/' + path;
  36. #endif // #ifdef BOOST_IOSTREAMS_WINDOWS
  37. }
  38. } } } // End namespaces detail, iostreams, boost.
  39. #endif // #ifndef BOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED