[Boost-bugs] [Boost C++ Libraries] #2260: Missing slash when iterating windows root path

Subject: [Boost-bugs] [Boost C++ Libraries] #2260: Missing slash when iterating windows root path
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-08-26 13:06:23


#2260: Missing slash when iterating windows root path
-----------------------------------------------------+----------------------
 Reporter: Lin Yi-Li <record.nctu.cis91_at_[hidden]> | Owner: bemandawes
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: filesystem
  Version: Boost 1.36.0 | Severity: Problem
 Keywords: directory_iterator seperator |
-----------------------------------------------------+----------------------
 A windows root path without backslash or slash, ex. "C:", will cause the
 result of directory_iterator missing a slash after ':'.
 For example, it will produce a broken path such as "C:filename".

 Here is a sample to produce this:
 {{{
 #include <iostream>
 #include <locale>
 #include <boost/filesystem.hpp>

 using namespace boost::filesystem;

 int main() {
         const char *drive_to_search = "C:";
         std::cout.imbue( std::locale());

         for( directory_iterator i( path( drive_to_search, native)), end; i
 != end; ++i) {
                 std::cout << i->path() << std::endl;
         }

         return 0;
 }
 }}}

 By tracing the stack, I think the problem is function
 boost::filesystem::basic_path<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>,boost::filesystem::wpath_traits>::m_append_separator_if_needed() won't
 append a slash in case of merging windows root path and filename.

 Here is the call stack starting at the constructor of directory_iterator.
 {{{
 boost::filesystem::basic_path<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>,boost::filesystem::wpath_traits>::m_append_separator_if_needed()
 boost::filesystem::basic_path<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>,boost::filesystem::wpath_traits>::operator/=(const wchar_t *)
 boost::filesystem::basic_path<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>,boost::filesystem::wpath_traits>::operator/=(const
 boost::filesystem::basic_path<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>,boost::filesystem::wpath_traits> & rhs)
 boost::filesystem::operator/<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>,boost::filesystem::wpath_traits>(const
 boost::filesystem::basic_path<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>,boost::filesystem::wpath_traits> & lhs, const
 std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
> & rhs)
 boost::filesystem::basic_directory_iterator<boost::filesystem::basic_path<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>,boost::filesystem::wpath_traits> >::m_init(const
 boost::filesystem::basic_path<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>,boost::filesystem::wpath_traits> & dir_path)
 boost::filesystem::basic_directory_iterator<boost::filesystem::basic_path<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>,boost::filesystem::wpath_traits>
>::basic_directory_iterator<boost::filesystem::basic_path<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>,boost::filesystem::wpath_traits> >(const
 boost::filesystem::basic_path<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>
>,boost::filesystem::wpath_traits> & dir_path)
 }}}

-- 
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2260>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC